def reset_container(): """ Resets the container for warm restart. Simple implementation currently. Used for testing only. """ # The following is extremely hacky. Reset static module and classvariables # to their defaults. Even further, reset imported names in other modules # to the new objects. base_process.procRegistry = Store() base_process.processes = {} base_process.receivers = [] spawnable.store = Container.store spawnable.Spawnable.progeny = {}
def _stop_container(self): """ Taking down the container's connection to the broker an preparing for reinitialization. """ logging.info("Closing ION container") self.test_sup = None dcs = reactor.getDelayedCalls() logging.info("Cancelling %s delayed reactor calls!" % len(dcs)) for dc in dcs: dc.cancel() self.cont_conn.transport.loseConnection() container.Container._started = False container.Container.store = Store() bootstrap.reset_container() logging.info("============ION container closed============")
def currenttime(): """ @retval current UTC time as float with seconds in epoch and fraction """ return time.time() def currenttime_ms(): """ @retval current UTC time as int with milliseconds in epoch """ return int(currenttime() * 1000) # Stuff for testing: Stubs, mock objects fakeStore = Store() class FakeMessage(object): """Instances of this object are given to receive functions and handlers by test cases, in lieu of carrot BaseMessage instances. Production code detects these and no send is done. """ def __init__(self, payload=None): self.payload = payload @defer.inlineCallbacks def send(self, to, msg): self.sendto = to self.sendmsg = msg # Need to be a generator