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

View File

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