Permalink
Browse files

Meant to use setdefault, not get. Whoops.

This fixes issues where a script might not get events if it was loaded too early.
  • Loading branch information...
1 parent a462c02 commit 53bad542660ecc6df02626bbfe209bd71160d717 @kg committed Jan 19, 2011
Showing with 3 additions and 4 deletions.
  1. +2 −2 Common/common.service.py
  2. +1 −2 DroneHelper/dronehelper.py
View
@@ -48,7 +48,7 @@ def forceStop(serviceName):
del runningServices[serviceName]
ne = getattr(serviceInstance, "__notifyevents__", [])
for evt in ne:
- nl = sm.notify.get(evt, [])
+ nl = sm.notify.setdefault(evt, list())
if serviceInstance in nl:
nl.remove(serviceInstance)
finally:
@@ -77,7 +77,7 @@ def forceStart(serviceName, serviceType):
if (not hasattr(result, evt)):
log("Missing event handler for %r on %r", evt, result)
else:
- nl = sm.notify.get(evt, [])
+ nl = sm.notify.setdefault(evt, list())
nl.append(result)
return result
@@ -87,7 +87,6 @@ class DroneHelperSvc:
def __init__(self):
self.__drones = {}
self.__pendingStateChanges = {}
- self.__updateTimer = None
self.__lastAttackOrder = None
self.__recalling = set()
self.__recalled = []
@@ -473,7 +472,7 @@ def getDroneObject(self, droneID):
drone = DroneInfo(droneID)
self.__drones[droneID] = drone
- return drone
+ return drone
def OnDroneStateChange2(self, droneID, oldActivityState, newActivityState, timestamp=None):
if not timestamp:

0 comments on commit 53bad54

Please sign in to comment.