mirror of
https://github.com/Justuser3310/jetwork.git
synced 2025-01-19 01:18:48 +00:00
Вероятно исправлена проблема с потоками
This commit is contained in:
parent
ed6ecbd282
commit
8b7c0772c1
34
network.py
34
network.py
@ -88,7 +88,7 @@ def server(http_port):
|
||||
except:
|
||||
print("SERVER FALLED")
|
||||
|
||||
def recv(q, s):
|
||||
def recv(data):
|
||||
okay = False
|
||||
while not okay:
|
||||
try:
|
||||
@ -96,9 +96,11 @@ def recv(q, s):
|
||||
okay = True
|
||||
except:
|
||||
pass
|
||||
q.put(data)
|
||||
# q.put(data)
|
||||
|
||||
import multiprocessing as mp
|
||||
from time import time
|
||||
from threading import Thread
|
||||
# op = operation
|
||||
def client(port, op = "ping"):
|
||||
host = 'jetwork.404.mn'
|
||||
@ -116,6 +118,7 @@ def client(port, op = "ping"):
|
||||
|
||||
s.send(op.encode())
|
||||
|
||||
'''
|
||||
# Канал обмена процесс - наша функция
|
||||
q = mp.Queue()
|
||||
# Стартуем процесс получения ответа
|
||||
@ -134,6 +137,30 @@ def client(port, op = "ping"):
|
||||
p.terminate()
|
||||
|
||||
s.close()
|
||||
'''
|
||||
|
||||
data = None
|
||||
ping = Thread(target = recv, args=(data,))
|
||||
ping.daemon = True
|
||||
ping.start()
|
||||
|
||||
'''
|
||||
# Засекаем когда мы начали ждать
|
||||
start = time()
|
||||
|
||||
# Ждём 10 секунд
|
||||
while time() - start < 3:
|
||||
pass
|
||||
|
||||
#try:
|
||||
# ping._stop()
|
||||
#except:
|
||||
# pass
|
||||
ping.kill()
|
||||
'''
|
||||
|
||||
ping.join(5)
|
||||
|
||||
|
||||
return data
|
||||
elif op[:4] == "get_":
|
||||
@ -234,3 +261,6 @@ def port_check(your_port):
|
||||
ports.append(port)
|
||||
|
||||
return ports
|
||||
|
||||
|
||||
#print(client(44, "ping"))
|
||||
|
Loading…
Reference in New Issue
Block a user