Thread exiting elegance.
parent
f81eae836d
commit
16ec61f4d6
12
__init__.py
12
__init__.py
|
@ -38,8 +38,12 @@ def run_phenny(config):
|
||||||
|
|
||||||
Watcher()
|
Watcher()
|
||||||
while True:
|
while True:
|
||||||
connect(config)
|
try: connect(config)
|
||||||
if not isinstance(delay, int): break
|
except KeyboardInterrupt:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if not isinstance(delay, int):
|
||||||
|
break
|
||||||
|
|
||||||
warning = 'Warning: Disconnected. Reconnecting in %s seconds...' % delay
|
warning = 'Warning: Disconnected. Reconnecting in %s seconds...' % delay
|
||||||
print >> sys.stderr, warning
|
print >> sys.stderr, warning
|
||||||
|
@ -47,7 +51,9 @@ def run_phenny(config):
|
||||||
|
|
||||||
def run(config):
|
def run(config):
|
||||||
t = threading.Thread(target=run_phenny, args=(config,))
|
t = threading.Thread(target=run_phenny, args=(config,))
|
||||||
t.start()
|
if hasattr(t, 'run'):
|
||||||
|
t.run()
|
||||||
|
else: t.start()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
4
irc.py
4
irc.py
|
@ -65,7 +65,9 @@ class Bot(asynchat.async_chat):
|
||||||
print >> sys.stderr, message,
|
print >> sys.stderr, message,
|
||||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.connect((host, port))
|
self.connect((host, port))
|
||||||
asyncore.loop()
|
try: asyncore.loop()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
|
|
Loading…
Reference in New Issue