Skip to content

Commit

Permalink
fix, actually kill url to unixtime threads that timed out
Browse files Browse the repository at this point in the history
fix, async wait only seconds (10) only once rather than wait for all pool

add test usr/share/sdwdate/get_time_from_servers_test
  • Loading branch information
Patrick Schleizer committed Sep 13, 2016
1 parent 36111e2 commit a79f622
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions usr/lib/python2.7/dist-packages/sdwdate/remote_times.py
Expand Up @@ -28,8 +28,10 @@ def get_time_from_servers(remotes, ip_address, port_number):
'80',
'0'], stdout=PIPE))

for i in range(len(threads)):
gevent.wait([threads[i]], timeout=seconds)
try:
gevent.wait(timeout=seconds)
except:
pass

for i in range(len(threads)):
if threads[i].poll() is not None:
Expand All @@ -39,6 +41,10 @@ def get_time_from_servers(remotes, ip_address, port_number):
else:
urls.append(remotes[i])
unix_times.append('Timeout')
try:
threads[i].terminate()
except:
pass

return urls, unix_times

Expand Down
8 changes: 8 additions & 0 deletions usr/share/sdwdate/get_time_from_servers_test
@@ -0,0 +1,8 @@
#!/usr/bin/python

import sys
from sdwdate.remote_times import get_time_from_servers

urls, unix_times = get_time_from_servers(["sejnfjrq6szgca7v.onion", "vtjkwwcq5osuo6uq.onion", "vtjkwwcq5osuo6uq.onion", "vtjkwwcq5osuo6uq.onion"], "127.0.0.1", "9050")

print urls, unix_times

0 comments on commit a79f622

Please sign in to comment.