You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from promise import Promise
from threading import Timer
from time import sleep
class MyClass:
def __init__(self):
self.p = None
def get_promise(self):
self.p = Promise()
def reject():
self.p.reject(Exception("qwe"))
def resolve():
self.p.fulfill("asd")
Timer(3, reject).start()
return self.p
i = MyClass()
def on_resolve(x):
print(str(x))
def on_reject(x):
print(str(x))
p = i.get_promise()
p.then(on_resolve, on_reject)
while 1:
sleep(1)
on_reject is never called in the master branch version (2.1.0). But it works fine in 1.0.1.
I've stepped through execution and I think I might have found the problem. I saw that the code goes to this function:
def _reject(self, reason, traceback=None):
self._state = STATE_REJECTED
self._fulfillment_handler0 = reason
self._traceback = traceback
if self._is_final:
assert self._length == 0
return async_instance.fatal_error(reason)
if self._length > 0:
async_instance.settle_promises(self)
else:
self._ensure_possible_rejection_handled() # the execution goes here
if self._is_async_guaranteed:
self._settle_promises()
else:
async_instance.settle_promises(self)
But _ensure_possible_rejection_handled does nothing:
This is my code:
on_reject
is never called in the master branch version (2.1.0). But it works fine in 1.0.1.I've stepped through execution and I think I might have found the problem. I saw that the code goes to this function:
But
_ensure_possible_rejection_handled
does nothing:Is it a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered: