Added user defined function for updater's signalHandler#512
Merged
jh0ker merged 5 commits intopython-telegram-bot:masterfrom Mar 26, 2017
d-qoi:UserSignalHandler
Merged
Added user defined function for updater's signalHandler#512jh0ker merged 5 commits intopython-telegram-bot:masterfrom d-qoi:UserSignalHandler
jh0ker merged 5 commits intopython-telegram-bot:masterfrom
d-qoi:UserSignalHandler
Conversation
Contributor
Author
|
There are 3 tests that fail with I am currently writing a test for this, I will update this pull request once it is written. If you would like me to squash the commits, I am happy to. |
jh0ker
requested changes
Feb 13, 2017
telegram/ext/updater.py
Outdated
| bot (Optional[Bot]): A pre-initialized bot instance. If a pre-initizlied bot is used, it is | ||
| the user's responsibility to create it using a `Request` instance with a large enough | ||
| connection pool. | ||
| user_sig_handler (Optional[function]: A function that takes ``signum, frame`` as positional arguments. |
Member
There was a problem hiding this comment.
You're missing a closing paranthesis here
Member
|
I left one minor request, everything else seems good to me |
Fixing paren
…bot into UserSignalHandler
jh0ker
approved these changes
Feb 27, 2017
Member
|
Python 2.7 tests fail at |
…n-telegram-bot into UserSignalHandler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was no good way to add new handlers for signal without overloading the ones updater.idle() created.
While updater.idle() is very simple, I thing that it is better to add this rather than encouraging users to re-write those functions.
The use of this is for anything that should be closed, like database connections, or shut down cleanly.
If I have a database connection at
dbI can insert it into the updater.
and assuming everything else is self as default, and logger is set to debug, we will get an output like this:
Which ends with the log output in the user defined signal handler, meaning the code has run.