Skip to content
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

Write() does not do a genuine async write #53

Closed
wolfmanjm opened this issue May 25, 2020 · 3 comments
Closed

Write() does not do a genuine async write #53

wolfmanjm opened this issue May 25, 2020 · 3 comments

Comments

@wolfmanjm
Copy link
Contributor

Strictly speaking the write() does not do a real async write if the write buffer is empty. Even though the serial.write() is non blocking, doing a real write there is technically incorrect IMO.

In addition as there is a bug in the posix serial.write() where writing to a port that is not ready will cause it to enter a tight loop continously throwing an EAGAIN exception, so we end up effectively with a blocking write. See pyserial/pyserial#280.

The code I modified (and use) here does a real async write (every write gets buffered and executed asynchronously. This also avoids the aforementioned bug in serial.write().

If this is something you feel is the correct way to do it, let me know and I'll submit a PR.

I do undestand that issuing a genuine serial.write() if the buffer is empyy maybe more efficient so I could undersand why my solution may not be acceptible. (that is presuming the serial.write() bug is fixed). I have a workaround in the existing write() that I could submit that also avoids that bug, but keeps the instant write if the write buffer is empty.

@rob-smallshire
Copy link
Collaborator

Can you make a PR for this please?

@wolfmanjm
Copy link
Contributor Author

Yes I'll do this ASAP. Been using it for a while now and it does the job nicely.

@rsippl
Copy link

rsippl commented Jul 6, 2020

Under heavy load, this issue (and the mentioned tight loop) is a show stopper. #56 works fine for me. Thanks, @wolfmanjm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants