def test_set_thread_state(): with set_thread_state(x=1): assert thread_state.x == 1 assert not hasattr(thread_state, "x")
def cb(self): while True: x = yield self.queue.get(asynchronous=True) with set_thread_state(asynchronous=True): result = self.emit(x) yield result
def _update(self, x, who=None): client = default_client() result = yield client.gather(x, asynchronous=True) with set_thread_state(asynchronous=True): result = self.emit(result) yield result
def test_set_thread_state(): with set_thread_state(x=1): assert thread_state.x == 1 assert not hasattr(thread_state, 'x')