Skip to content

Commit 63f7209

Browse files
committed
add breaking condition, Sink.destroy test uses the base Sink class
1 parent 2a3390a commit 63f7209

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

streamz/sources.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,4 +763,7 @@ def start(self):
763763
@gen.coroutine
764764
def _run(self):
765765
for x in self._iterable:
766+
if self.stopped:
767+
break
766768
yield self._emit(x)
769+
self.stopped = True

streamz/tests/test_sinks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
from streamz import Stream
5-
from streamz.sinks import _global_sinks
5+
from streamz.sinks import _global_sinks, Sink
66
from streamz.utils_test import tmpfile
77

88

@@ -62,7 +62,7 @@ def test_sink_to_textfile_closes():
6262

6363
def test_sink_destroy():
6464
source = Stream()
65-
sink = source.sink(lambda x: None)
65+
sink = Sink(source)
6666
ref = weakref.ref(sink)
6767
sink.destroy()
6868
del sink

0 commit comments

Comments
 (0)