nanomsg / nnpy

cffi-based Python bindings for nanomsg
MIT License
117 stars 39 forks source link

No support for NN_DONTWAIT? #20

Closed adaszko closed 8 years ago

adaszko commented 8 years ago

That the NN_DONTWAIT constant isn't defined anywhere the nnpy lib is a hint enough of it being unsupported, but if I try to pass it nonetheless, I'm getting AssertionError:

In [16]: pair.recv(flags=1)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-16-35a907a09301> in <module>()
----> 1 pair.recv(flags=1)

./lib/python2.7/site-packages/nnpy/socket.pyc in recv(self, flags)
     62         buf = ffi.new('char**')
     63         rc = nanomsg.nn_recv(self.sock, buf, NN_MSG, flags)
---> 64         assert rc > 0, rc
     65         s = ffi.buffer(buf[0], rc)[:]
     66         nanomsg.nn_freemsg(buf[0])

AssertionError: -1

It looks like adding it wouldn't be much work. Is there a chance of it happening?

djc commented 8 years ago

Well, nnpy.DONTWAIT seems to be defined for me. Does that fail for you?

I just pushed 656d2ace1940d8f45d8f52cc2b2fbbad4279e9c0 to master, which should throw a human-readable exception rather than a content-free AssertionError. Maybe give it a shot?

djc commented 8 years ago

Since there has been no further response, I'll close this for now. Please reopen if you still think it is an issue.

adaszko commented 8 years ago

Yeah, sorry about that. You were right — nnpy.DONTWAIT is defined. It is just the lack of a specific exception class that confused me. Thanks for your answer.

djc commented 8 years ago

No problem! What did you expect in terms of a specific exception class? Maybe I could implement something for that. (It would be useful if you linked to examples of such classes in other Python libraries.)