-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle EAGAIN on write (BlockingIOError: [Errno 11] Resource temporar… #227
Conversation
OK but the fix only works for Python 3, that Exception name is not present in Python 2.7 (I need to review #225 too). |
oh I am sorry I forgot to test on 2.7 as asyncio only works on 3... I'll see what I can do for 2.7. |
I've ported the code from the socket handler here and saw that EINTR was not handled for Py 2.7 while it was for 3.x. So you do not need to provide an updated patch, but thanks for finding the issue. |
@zsquareplusc Thank you, however that fix is for read. The error I get is with write not the read. |
- catch all the errno's that BlockingIOError would cover - catch EINTR fixes #227
OK, i think it makes sense to catch the same errors in read and write, pushed a change with that. |
Hi @zsquareplusc I just tested your fix.. however I now get this error... Seems that it still is not handling non blocking mode correctly on writes.
|
ok the issue appears to be here... Line 135 in 10d79d9
even though the Timeout is set to 0 ie non blocking this Line 129 in 10d79d9
|
Changing Line 147 in 10d79d9
to if duration is not None and duration != 0: seems to fix this issue, but I am not convinced that is correct, what do you think? |
Possibly the correct fix is to do what was there originally and not call in pyserial/serial/serialposix.py Line 576 in 10d79d9
unless there is an exception. or possibly not, as checking timeout for a non blocking port seems inconsistent and possibly incorrect, and in this case would still generate a bogus timeout exception. |
It was probably broken before that change too... (your fix had a separate The timeout object returns |
SKip the test for non blocking write in posixserial or in Timeout? I am not clear where to exactly fix this :) |
Ahh ok never mind I see your fix, thank you I'll test it ASAP. |
Thank you... I tested the latest and it works perfectly. |
- catch all the errno's that BlockingIOError would cover - and catch EINTR in for both blocks, for Py 2.7 and 3.x fixes pyserial#227
- catch all the errno's that BlockingIOError would cover - catch EINTR fixes pyserial#227
…ily unavailable)
As the pyserial-asyncio uses non blocking mode posix serial needs to handle the EAGAIN error which is a non fatal error that is often seen in non blocking mode.
Without it we get this error in asyncio mode when writing a lot of data..
Fixes this issue pyserial/pyserial-asyncio#20