Skip to content

Commit eddf37c

Browse files
committed
fix bug
1 parent 8dfc6d4 commit eddf37c

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

clients/client-linux.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,7 @@ def _monitor_thread(name, host, interval, type):
324324
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
325325
while True:
326326
if name not in monitorServer.keys():
327-
monitorServer[name] = {
328-
"type": type,
329-
"dns_time": 0,
330-
"connect_time": 0,
331-
"download_time": 0,
332-
"online_rate": 1
333-
}
327+
break
334328
if packet_queue.full():
335329
if packet_queue.get() == 0:
336330
lostPacket -= 1
@@ -459,6 +453,13 @@ def byte_str(object):
459453
for i in data.split('\n'):
460454
if "monitor" in i and "type" in i and "{" in i and "}" in i:
461455
jdata = json.loads(i[i.find("{"):i.find("}")+1])
456+
monitorServer[jdata.get("name")] = {
457+
"type": jdata.get("type"),
458+
"dns_time": 0,
459+
"connect_time": 0,
460+
"download_time": 0,
461+
"online_rate": 1
462+
}
462463
t = threading.Thread(
463464
target=_monitor_thread,
464465
kwargs={
@@ -524,11 +525,13 @@ def byte_str(object):
524525
except KeyboardInterrupt:
525526
raise
526527
except socket.error:
528+
monitorServer.clear()
527529
print("Disconnected...")
528530
if 's' in locals().keys():
529531
del s
530532
time.sleep(3)
531533
except Exception as e:
534+
monitorServer.clear()
532535
print("Caught Exception:", e)
533536
if 's' in locals().keys():
534537
del s

clients/client-psutil.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,7 @@ def _monitor_thread(name, host, interval, type):
312312
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
313313
while True:
314314
if name not in monitorServer.keys():
315-
monitorServer[name] = {
316-
"type": type,
317-
"dns_time": 0,
318-
"connect_time": 0,
319-
"download_time": 0,
320-
"online_rate": 1
321-
}
315+
break
322316
if packet_queue.full():
323317
if packet_queue.get() == 0:
324318
lostPacket -= 1
@@ -444,10 +438,16 @@ def byte_str(object):
444438
if data.find("You are connecting via") < 0:
445439
data = byte_str(s.recv(1024))
446440
print(data)
447-
monitorServer.clear()
448441
for i in data.split('\n'):
449442
if "monitor" in i and "type" in i and "{" in i and "}" in i:
450443
jdata = json.loads(i[i.find("{"):i.find("}")+1])
444+
monitorServer[jdata.get("name")] = {
445+
"type": jdata.get("type"),
446+
"dns_time": 0,
447+
"connect_time": 0,
448+
"download_time": 0,
449+
"online_rate": 1
450+
}
451451
t = threading.Thread(
452452
target=_monitor_thread,
453453
kwargs={
@@ -514,11 +514,13 @@ def byte_str(object):
514514
except KeyboardInterrupt:
515515
raise
516516
except socket.error:
517+
monitorServer.clear()
517518
print("Disconnected...")
518519
if 's' in locals().keys():
519520
del s
520521
time.sleep(3)
521522
except Exception as e:
523+
monitorServer.clear()
522524
print("Caught Exception:", e)
523525
if 's' in locals().keys():
524526
del s

0 commit comments

Comments
 (0)