Add with statement to example in README.md#1435
Conversation
Not using with expression in code might cause lack of cleanup and hard to trace errors, also because Bus doesn't override __del__. So it's a good idea to provide a 100% percent correct example in README for people who don't go into examples folder and read into the code.
| @@ -91,21 +91,21 @@ Example usage | |||
|
|
|||
| # create a bus instance | |||
There was a problem hiding this comment.
| # create a bus instance | |
| # create a bus instance (using a context manager to call `Bus.shutdown()` after use) |
There was a problem hiding this comment.
I added a similar comment but with "with" statement instead of context manager, because people might know about it from using files but not know the name "context manager".
In this case there should also be a But I think most of users, including me, prefer to shutdown it manually and not depend on garbage collection. |
Yeah, or the "double calling" should be taken care of by the subclass. You approach is probably simplest. It was just meant like a "last resort". I think you should never really rely on |
|
See #1448 for a discussion on |
Not using with expression in code might cause lack of cleanup and hard to trace errors, also because Bus doesn't override
__del__.So it's a good idea to provide a 100% percent correct example in README for people who don't go into examples folder and read into the code.
Not sure if a sleep call is not needed after the notifier though.