def __notified(self, request): notify(REQUEST_STARTS, request) response = None try: response = func(self, request) return response finally: notify(REQUEST_ENDS, response)
def _sigterm(self, signal, frame): self.shutting = True # wait for a bit sleep(self.graceful_shutdown_interval) # no more queries self.killing = True # wait for a bit sleep(self.hard_shutdown_interval) # now we can notify the end -- so pending stuff can be cleaned up notify(APP_ENDS) # bye-bye sys.exit(0)
def test_host_config(self): def alice(data): data.append('alice') def bob(data): data.append('bob') subscribe('yo', alice) subscribe('yo', bob) subscribe('yo', bob) # will be ignored stuff = [] notify('yo', stuff) self.assertEquals(stuff, ['alice', 'bob']) unsubscribe('yo', alice) notify('yo', stuff) self.assertEquals(stuff, ['alice', 'bob', 'bob'])