I have a question.
A recvfrom() function in Digi Python Programming Guide,
page 19.
Description has MSG_DONTWAIT flag.
Digi’s socket module supports this flag?
A exception occurs when I set this flag to recvfrom().
I have a question.
A recvfrom() function in Digi Python Programming Guide,
page 19.
Description has MSG_DONTWAIT flag.
Digi’s socket module supports this flag?
A exception occurs when I set this flag to recvfrom().
What is the exact traceback text? Do you have a small example that fails in this way? The MSG_DONTWAIT flag, to the best of my knowledge, is fully supported.
Is, perhaps, the exception you are receiving:
(11, ‘No more processes’)
If so, that is the expected behavior. Error 11 is “EAGAIN”, the error one expects from a BSD non-blocking socket if no data is available.
One way to see the UNIX-style errno name for an error number is to use the errno module. Example:
>>> from errno import errorcode
>>> print errorcode[11]
EAGAIN
>>>
Thank you for your reply and advice.
I modified my test code. I attach it.
I could handle exception error from recvfrom() with MSG_DONTWAIT flag.
A recvfrom() method raises an exception with EAGAIN, exactly.
I could confirm a behavior of recvfrom() with non-blocking.
Also, I checked sd.setblocking(0) operation.
I understood that this way could achives non-blocking operation, too.
Thank you.
Another recommendation. Have you considered the use of the select module? Using MSG_DONTWAIT in a loop like this will “busy wait”, wasting CPU cycles. If you use select with a timeout, the “isSet” test might be delayed (by the timeout), but the system would otherwise block until frame reception. My assumption is that the exit test is not as timing sensitive as the response to incoming data.
Yes, I am considering about select().
I will try it at next step.
Thank you for your advice!