aio-libs / aiozmq

Asyncio (pep 3156) integration with ZeroMQ
aiozmq.readthedocs.org
BSD 2-Clause "Simplified" License
422 stars 56 forks source link

Please provide a way to cach route error #49

Closed akhilman closed 9 years ago

akhilman commented 9 years ago

Greetings.

in https://github.com/aio-libs/aiozmq/blob/master/aiozmq/core.py#L266 transoport's write method returns None in both cases when socket.write raises error or when message sended successfully. So I can't figure out is message was sent. Please make transport's write method raise exception if it can't send message.

akhilman commented 9 years ago

Ok. seems I can monkey patch _fatal_error. Is it right way?

asvetlov commented 9 years ago
  1. aiozmq transports follow asyncio design: transport.write() returns immediately and never reports about network problems
  2. You should never monkey patch transport nor derive from it. All network errors reported to protocol via proto.connection_lost(exc) callback.
  3. I recommend to use streams instead of transports/protocols, see http://aiozmq.readthedocs.org/en/0.6/#getting-started for example. If you need to wait for sending message through the wire use yield from stream.drain().