Closed wrobell closed 8 years ago
This is pretty much an entirely different Socket
implementation, right? As such, maybe it makes more sense to put this in a separate package and rely on the CFFI bindings from nnpy
if that helps. Since I don't have much expertise in asyncio
, nor the interest to learn it right now, I don't really want to maintain code like this.
I would not call it entirely different. :) It just adds asynchronous coroutines to the API. You could have SocketAsync
class like above or alternatively Socket.recv_async
and Socket.send_async
coroutines.
Looking at pyzmq
, they provide zmq.aiosync
module, but there is also separate library aiozmq
.
If you need concurrency, how would you use nnpy
? Is the API thread-safe?
I think the API is as thread-safe as the nanomsg one. For more details on that, you'd probably have to dive into nanomsg documentation, and/or ask their community.
Another problem with merging asyncio
support is that nnpy
supports both Python 2 and Python 3 for now, and as I understand it the code you propose only works on Python 3. The other question is, how hard is it to build asyncio
support around a Socket
, rather than into it. As Socket
is a very thin layer, it doesn't seem so hard to build your async primitives on top of it.
OK. See https://github.com/wrobell/aionn.
Cool. Once you think it's in a good enough shape, maybe put up a pull request to link to it from nnpy
's README?
Should it be done with addition to README file like
Related Projects
----------------
- `nanomsg website <http://nanomsg.org/>`_
- `aionn - asyncio messaging library based on nanomsg and nnpy <https://github.com/wrobell/aionn>`_
?
Yup, something like that seems good!
It would be great to support asyncio.
Asyncio socket class implementation (depends on #25) with sample usage below. This is bit hacky implementation
send
andrecv
methods are coroutinesloop.add_reader
andloop.add_writer
Socket.poll
is used to double check that data can be received from or sent to the SP socketSocket.poll
tells that it is not possible to receive/send data without blocking, then the hackery startsShould
nnpy
supportasyncio
? Is API based onSocketAsync
class OK?