Skip to content

Commit

Permalink
Fix loopless trasport implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Sep 27, 2014
1 parent b46871f commit 5ac03fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
CHANGES
-------

0.5.0 (XXXX-XX-XX)
0.5.1 (2014-09-27)
^^^^^^^^^^^^^^^^^^

* Fix loopless transport implementation.

0.5.0 (2014-08-23)
^^^^^^^^^^^^^^^^^^

* Support zmq devices in aiozmq.rpc.serve_rpc()
Expand Down
2 changes: 1 addition & 1 deletion aiozmq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'create_zmq_connection',
'version_info', 'version')

__version__ = '0.5.0'
__version__ = '0.5.1'

version = __version__ + ' , Python ' + sys.version

Expand Down
13 changes: 12 additions & 1 deletion aiozmq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,10 @@ def __init__(self, loop, zmq_type, zmq_sock, protocol, waiter):

self._loop.call_soon(self._protocol.connection_made, self)
self._loop.call_soon(waiter.set_result, None)
self._soon_call = None

def _read_ready(self):
self._soon_call = None
if self._zmq_sock is None:
return
events = self._zmq_sock.getsockopt(zmq.EVENTS)
Expand All @@ -589,7 +591,7 @@ def _read_ready(self):
else:
schedule = False
if schedule:
self._loop.call_soon(self._read_ready)
self._soon_call = self._loop.call_soon(self._read_ready)

def _do_read(self):
try:
Expand Down Expand Up @@ -628,6 +630,9 @@ def _do_write(self):
if not self._buffer and self._closing:
self._loop.remove_reader(self._fd)
self._call_connection_lost(None)
else:
if self._soon_call is None:
self._soon_call = self._loop.call_soon(self._read_ready)

def _do_send(self, data):
try:
Expand Down Expand Up @@ -666,6 +671,12 @@ def _do_pause_reading(self):
def _do_resume_reading(self):
self._read_ready()

def _call_connection_lost(self, exc):
try:
super()._call_connection_lost(exc)
finally:
self._soon_call = None


class ZmqEventLoopPolicy(asyncio.AbstractEventLoopPolicy):
"""ZeroMQ policy implementation for accessing the event loop.
Expand Down

0 comments on commit 5ac03fe

Please sign in to comment.