1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

fix 'hangup' to finish all threads

This commit is contained in:
urlbot
2015-06-20 14:18:50 +02:00
parent 32366f5ce6
commit 0b63a09077
2 changed files with 11 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ joblist = []
plugins = {p : [] for p in ptypes} plugins = {p : [] for p in ptypes}
got_hangup = False
def pluginfunction(name, desc, plugin_type, ratelimit_class = RATE_GLOBAL, enabled = True): def pluginfunction(name, desc, plugin_type, ratelimit_class = RATE_GLOBAL, enabled = True):
''' A decorator to make a plugin out of a function ''' ''' A decorator to make a plugin out of a function '''
if plugin_type not in ptypes: if plugin_type not in ptypes:
@@ -736,6 +738,8 @@ def else_command(args):
} }
def data_parse_commands(msg_obj): def data_parse_commands(msg_obj):
global got_hangup
data = msg_obj['body'] data = msg_obj['body']
words = data.split() words = data.split()
@@ -748,6 +752,7 @@ def data_parse_commands(msg_obj):
if 'hangup' in data: if 'hangup' in data:
logger('warn', 'received hangup: ' + data) logger('warn', 'received hangup: ' + data)
got_hangup = True
sys.exit(1) sys.exit(1)
return None return None
@@ -857,6 +862,9 @@ def register_all():
register(ptypes_COMMAND) register(ptypes_COMMAND)
def event_trigger(): def event_trigger():
if got_hangup:
return False
if 0 == len(joblist): if 0 == len(joblist):
return return

View File

@@ -314,7 +314,9 @@ if '__main__' == __name__:
while 1: while 1:
try: try:
plugins.event_trigger() if False == plugins.event_trigger():
xmpp.disconnect()
sys.exit(1)
time.sleep(delay) time.sleep(delay)
except KeyboardInterrupt: except KeyboardInterrupt: