-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[BUG] promise mistreats pooled_function exceptions as done_callback exceptions #2542
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
Comments
Hi. Thanks for the detailed report! 👍 Seems like we overlooked the fact that Please note that |
+1, as we don't know what will be the future of Promise in asyncio, it's better to just call the done callback when promise didn't raise an exception. |
…_function exceptions in Promise send the pooled_function exception back through done_callback instead of eating it up, mistreating it as a done_callback exception
IMO the fix is simple: #2543 |
Steps to reproduce
telegram.ext.utils.Promise
, throw an exception from thepooled_function
on which the promise was built.DelayQueue
using@mq.queuedmessage
decorator on a subclassed Bot class. any exception like TimeOut or flood control within asend_message
for example ends up with this problemIf you get any telegram exception, it just gets eaten up by Promise's run method in this specific area:
Here's the bug: even if there's an exception in
self.result()
it will treat it as an exception fromself._done_callback()
which isn't correct.The funny thing is that code speaks out the problem on its own:
if there's an exception in
pooled_function
, it is stored inself._exception
and then it is raised from
self.result()
:why? this way all exception from
pooled_function
are forcibly going to be taken as exceptions ofdone_callback
, eaten up by the promise code and never raised.Expected behaviour
Promise
should ideally have another method calledadd_exception_callback
or similar just likeadd_done_callback
, and pass any exception frompooled_function
to that callbackActual behaviour
Promise mistreats
pooled_function
exceptions asdone_callback
exceptionsConfiguration
Operating System:
linux
Version of Python, python-telegram-bot & dependencies:
Logs
Insert logs here (if necessary)
The text was updated successfully, but these errors were encountered: