|
|
@ -96,9 +96,7 @@ def recv(data):
|
|
|
|
okay = True
|
|
|
|
okay = True
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
# q.put(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import multiprocessing as mp
|
|
|
|
|
|
|
|
from time import time
|
|
|
|
from time import time
|
|
|
|
from threading import Thread
|
|
|
|
from threading import Thread
|
|
|
|
# op = operation
|
|
|
|
# op = operation
|
|
|
@ -118,48 +116,14 @@ def client(port, op = "ping"):
|
|
|
|
|
|
|
|
|
|
|
|
s.send(op.encode())
|
|
|
|
s.send(op.encode())
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Канал обмена процесс - наша функция
|
|
|
|
|
|
|
|
q = mp.Queue()
|
|
|
|
|
|
|
|
# Стартуем процесс получения ответа
|
|
|
|
|
|
|
|
p = mp.Process(target=recv, args=(q, s))
|
|
|
|
|
|
|
|
p.start()
|
|
|
|
|
|
|
|
# Ждём 10 секунд - максимум
|
|
|
|
|
|
|
|
p.join(10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
data = q.get(block=False)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
data = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Если процесс жив - убираем
|
|
|
|
|
|
|
|
if p.is_alive():
|
|
|
|
|
|
|
|
p.terminate()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.close()
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = None
|
|
|
|
data = None
|
|
|
|
ping = Thread(target = recv, args=(data,))
|
|
|
|
ping = Thread(target = recv, args=(data,))
|
|
|
|
ping.daemon = True
|
|
|
|
ping.daemon = True
|
|
|
|
|
|
|
|
# Стартуем пинг
|
|
|
|
ping.start()
|
|
|
|
ping.start()
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
# Ждём 8 секунд
|
|
|
|
# Засекаем когда мы начали ждать
|
|
|
|
ping.join(8)
|
|
|
|
start = time()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ждём 10 секунд
|
|
|
|
|
|
|
|
while time() - start < 3:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#try:
|
|
|
|
|
|
|
|
# ping._stop()
|
|
|
|
|
|
|
|
#except:
|
|
|
|
|
|
|
|
# pass
|
|
|
|
|
|
|
|
ping.kill()
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ping.join(5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
return data
|
|
|
@ -264,3 +228,4 @@ def port_check(your_port):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#print(client(44, "ping"))
|
|
|
|
#print(client(44, "ping"))
|
|
|
|
|
|
|
|
port_check(4001)
|
|
|
|