1
0
mirror of https://github.com/balkian/TwitterDigger.git synced 2024-11-22 16:22:28 +00:00

Added Ctrl+C

This commit is contained in:
J.Fernando Sánchez 2013-03-15 13:27:31 +01:00
parent 417bfc9b10
commit b6cb81892d

View File

@ -63,6 +63,13 @@ def explore_user(t,uid):
pending.add(follo)
distance[follo] = newdist
def signal_handler(signal, frame):
print 'You pressed Ctrl+C!'
sh.close()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
while True:
try:
print "Iteration!"
@ -79,6 +86,7 @@ while True:
nextuser=user
explore_user(t,nextuser)
pending.remove(nextuser)
sh.sync()
time.sleep(5)
except TwitterHTTPError as ex:
print "Exception %s - %s" % (ex,type(ex))
@ -88,4 +96,8 @@ while True:
except IncompleteRead:
print "IncompleteRead!"
time.sleep(5)
except Exception as ex:
print "Exception"
sh.close()
raise ex