def test_separate_thread_with_time(loop, thread): L = [] @gen.coroutine def slow_write(x): yield gen.sleep(0.1) L.append(x) source = Stream(loop=loop) source.map(inc).sink(slow_write) start = time() source.emit(1) stop = time() assert stop - start > 0.1 assert L == [2]
def test_destroy(): source = Stream() s = source.map(inc) L = s.sink_to_list() source.emit(1) assert L == [2] s.destroy() assert not list(source.parents) assert not s.children source.emit(2) assert L == [2]
def test_gc(): source = Stream() L = [] a = source.map(L.append) source.emit(1) assert L == [1] del a import gc; gc.collect() start = time() while source.downstreams: sleep(0.01) assert time() < start + 1 source.emit(2) assert L == [1]