osvenskan / posix_ipc

Other
139 stars 25 forks source link

MessageQueue receive doesn't take timeout parameter #19

Closed ForeverWintr closed 5 years ago

ForeverWintr commented 5 years ago

It looks like the documentation for MessageQueue.receive is incorrect. It shows the signature as receive([timeout = None]), but if I try to pass a timeout I get TypeError: function takes at most 1 argument (2 given).

It looks like the source indeed doesn't receive a timeout parameter. Was this deliberate?

Thanks a ton for this library!

osvenskan commented 5 years ago

Prior to posix_ipc 1.0.3 (released Jan 2018), receive() didn't accept timeout as a keyword argument despite being documented to do so. It has always accepted timeout as a positional argument. Under posix_ipc > 1.0.3 (including the current 1.0.4), both the positional and keyword version of the timeout argument should work --

$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import posix_ipc
>>> posix_ipc.__version__
'1.0.4'
>>> mq = posix_ipc.MessageQueue(None, posix_ipc.O_CREX)
>>> mq.send('x')
>>> mq.receive(.2)
(b'x', 0)
>>> mq.send('x')
>>> mq.receive(timeout=.2)
(b'x', 0)
>>> 

Can you provide more detail about where you're seeing a problem?

Thanks a ton for this library!

You're welcome!

ForeverWintr commented 5 years ago

You're right, of course.

Strange. I must've been doing something silly, which I can no longer reproduce. And apparently I misunderstood the source as well. The dangers of pulling an all nighter...

Sorry for the false report!