Added thread safety to Zeroconf.close()#41
Conversation
Zeroconf.close() immediately closed sockets which child threads may still need to finish their operations. This was causing EBADF (bad file descriptor) errors in some cases. Zeroconf.close() now blocks until all known child threads have stopped then closes the sockets safely. If a child thread was created that Zeroconf is not aware of (ie a ServiceBrowser object manually created but not registered in zeroconf.browsers) the EBADF errors may still occur. Also some of the unit tests were not in a unittest.TestCase subclass so they were not running. Added test cases to Misc TestCase and added default execution of unittest.main().
|
Hey @justingiorgi, thank you for the contribution. One correction - all tests are running just fine, proof: https://travis-ci.org/jstasiak/python-zeroconf/jobs/94120747 ( With that in mind can you commit again just the changes related to the issue you experienced? |
|
Hey Jakub, that makes sense. Sorry I'm not familiar with nose. I've removed On Thu, Mar 10, 2016 at 2:11 PM Jakub Stasiak notifications@github.com
|
|
Thanks so much for the pull request. I made several improvements to ZC() shutdown, including incorporating these changes, before I had access to this repo. As of now I believe the functionality from this PR has been incorporated, and I unfortunately have no good way to merge the PR to give you credit for the change, so I am going to close it. If you think this an error, or an otherwise bad idea, please comment back. Thanks again for your help. |
Zeroconf.close() immediately closed sockets which child threads may
still need to finish their operations. This was causing EBADF (bad file
descriptor) errors in some cases. Zeroconf.close() now blocks until all
known child threads have stopped then closes the sockets safely. If a
child thread was created that Zeroconf is not aware of (ie a
ServiceBrowser object manually created but not registered in
zeroconf.browsers) the EBADF errors may still occur.
Also some of the unit tests were not in a unittest.TestCase subclass so
they were not running. Added test cases to Misc TestCase and added
default execution of unittest.main().