Reject function in Promise
mega7star opened this issue · 2 comments
mega7star commented
Why i not get a value from reject function?
Example:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from promise import Promise
>>> def test(x):
... def my(resolve, reject):
... if x > 0:
... resolve(x)
... else:
... reject(x)
... return Promise(my)
...
>>>
>>> test(42).then(lambda x: print('Test: ', x))
Test: 42
<promise.promise.Promise object at 0x0000004620FB9CC0>
>>>
>>> test(-42).then(None, lambda x: print('Test: ', x))
Test: # <------------- why not 'Test: -42' ?
<promise.promise.Promise object at 0x0000004620FC1908>
>>>
Globegitter commented
I seem to be running into some issues related to throwing errors on the server side as well. Just looking into those.
syrusakbary commented
I simplified a little bit the promise function init resolver.
This should fix the issue in master
.
I also added a test for assuring we are "guarded" for future versions: 74d8d19