-
Notifications
You must be signed in to change notification settings - Fork 6
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
open() bug in RFC2217Serial... #1
Comments
BTW, the same problem exists in PySerial 3.0. |
i have checked in a fix in pySerial 3.x but had not yet time to test it properly. I guess i would not fix that in the older releases. The new pySerial should be mostly backwards compatible so that the older ones are no longer needed. |
If you don't mind, I'd really like to see a 2.7.x released. 3.x is still pretty new, and the internals have had quite a bit of churn. For my project, PySerial is being used in a number of places, and we simply can't take on that risk right now. When 3.x hits stable and we get some cycles to test it thoroughly, then we can make that switch. Thanks! |
So I take it there will be no 2.7.x release with this fix? :-( |
The bug is in the RFC2217Serial class's open method:
The problem is when negotiations fail for some reason, and the
SerialException
is raised. If we make it to this point, the read thread is kept running in the background and the socket remains open as well. In our case, the RFC2217-capable device only allows one active connection at a time, so we can no longer re-establish our connection.There are a few fixes that could be made. The first, and probably simplest, would be to make the setting of
self._isOpen
toTrue
to before the creation of the read thread. That way if negotiations fail, theclose()
method can do its thing and tear the connection and the thread down.The second option would be to close the socket and teardown the thread, then raise the SerialException. Since it's so close to wait the
close()
method does, it seems a bit redundant to take this approach.A third option would be to change the
close()
implementation to something like this:Then it's no longer keying on
_isOpen
to know whether to tear everything down. It looks at the actual resources and tears them down as necessary.I prefer the first solution or the last solution, but thought I'd ask before filing a pull request.
The text was updated successfully, but these errors were encountered: