Skip to content

Commit

Permalink
Merge pull request #86 from akhoronko/master
Browse files Browse the repository at this point in the history
Use passed to create_zmq_stream events_backlog parameter
  • Loading branch information
asvetlov committed Dec 7, 2016
2 parents 6c5f5ed + ba27b2a commit 3b8dc02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiozmq/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def create_zmq_stream(zmq_type, *, bind=None, connect=None,
"""
if loop is None:
loop = asyncio.get_event_loop()
stream = ZmqStream(loop=loop, high=high_read, low=low_read)
stream = ZmqStream(loop=loop, high=high_read, low=low_read,
events_backlog=events_backlog)
tr, _ = yield from create_zmq_connection(
lambda: stream._protocol,
zmq_type,
Expand Down
25 changes: 25 additions & 0 deletions tests/zmq_stream_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,31 @@ def f(s, events):

self.loop.run_until_complete(go())

def test_default_events_backlog(self):
@asyncio.coroutine
def go():
s1 = yield from aiozmq.create_zmq_stream(
zmq.DEALER,
bind='tcp://127.0.0.1:*',
loop=self.loop)

self.assertEqual(100, s1._event_queue.maxlen)

self.loop.run_until_complete(go())

def test_custom_events_backlog(self):
@asyncio.coroutine
def go():
s1 = yield from aiozmq.create_zmq_stream(
zmq.DEALER,
bind='tcp://127.0.0.1:*',
loop=self.loop,
events_backlog=1)

self.assertEqual(1, s1._event_queue.maxlen)

self.loop.run_until_complete(go())


if __name__ == '__main__':
unittest.main()

0 comments on commit 3b8dc02

Please sign in to comment.