From 7446e24ba56aeb1524db92e6a2090cdb39e08b85 Mon Sep 17 00:00:00 2001 From: Stefan Krulj Date: Sat, 22 Jun 2013 11:55:08 +0200 Subject: [PATCH] hopefully "CallAt dictionary-bug" in now _really_ fixed, callAt-functionality should be threadsave now --- sys/brathuhn.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/brathuhn.py b/sys/brathuhn.py index 1d7f3a0..419015d 100644 --- a/sys/brathuhn.py +++ b/sys/brathuhn.py @@ -9,17 +9,18 @@ IGNORE_FIRST = 10 last_connect = 0 reconnect = False -commands = dict() -commands_private = dict() +commands = {} +commands_private = {} group_listeners = [] private_listeners = [] status_listeners = [] -call_ats = dict() +call_ats = {} call_ats_remove = [] +call_ats_append = {} call_ats_id = 0 join_time = time.time()+60*60*24*365 #1 year in the future -users = dict() +users = {} STATUS_JOIN, STATUS_ONLINE, STATUS_OFFLINE, STATUS_RENAME, STATUS_XAWAY, STATUS_AWAY, STATUS_UNKNOWN = range(7) SI, JINGLE = range(2) @@ -273,6 +274,7 @@ def loop(): """Loop forever and handle the event-queue.""" global last_connect global call_ats + global call_ats_append global reconnect while True: try: @@ -295,6 +297,9 @@ def loop(): to_remove.append(cid) for cid in to_remove + call_ats_remove: del call_ats[cid] + while len(call_ats_append)>0: + cid,call = call_ats_append.popitem() + call_ats[cid] = call except xmpp.protocol.Conflict: print "detected another connection, quitting..." @@ -325,9 +330,9 @@ def callAt(func,_time,*args): @param func -- Function to be called @param time -- The time when the message will be called""" - global call_ats + global call_ats_append global call_ats_id - call_ats[call_ats_id]=[func,_time,args] + call_ats_append[call_ats_id]=[func,_time,args] call_ats_id+=1 return call_ats_id-1