syrusakbary / promise

Ultra-performant Promise implementation in Python
MIT License
362 stars 76 forks source link

Fix race condition when pending Promise was resolved in other thread #89

Open alex-verve opened 4 years ago

alex-verve commented 4 years ago

I had to pin pytest* deps to make tests working again (new versions of pytest-cov and pytest-asyncio are not supported by latest pytest version for pypy)

Fixes https://github.com/syrusakbary/promise/issues/87

Test failure (without fix) - https://travis-ci.org/github/syrusakbary/promise/builds/708825617 Test passed here (with fix) - https://travis-ci.org/github/syrusakbary/promise/builds/708827378

alex-verve commented 4 years ago

There is at least one more race-condition in PromisList

  File "/var/task/promise/promise.py", line 97, in try_catch
    return (handler(*args, **kwargs), None)
, 
  File "/var/task/graphql/execution/executor.py", line 260, in <lambda>
    resolved
, 
  File "/var/task/graphql/execution/executor.py", line 288, in complete_value
    return complete_object_value(exe_context, return_type, field_asts, info, result)
, 
  File "/var/task/graphql/execution/executor.py", line 382, in complete_object_value
    return execute_fields(exe_context, return_type, result, subfield_asts)
, 
  File "/var/task/graphql/execution/executor.py", line 146, in execute_fields
    return promise_for_dict(final_results)
, 
  File "/var/task/promise/promise.py", line 816, in for_dict
    return cls.all(m.values()).then(handle_success)
, 
  File "/var/task/promise/promise.py", line 796, in all
    return PromiseList(promises, promise_class=cls).promise
, 
  File "/var/task/promise/promise_list.py", line 40, in __init__
    self._init(values)  # type: ignore
, 
  File "/var/task/promise/promise_list.py", line 72, in _init
    self._iterate(values)
, 
  File "/var/task/promise/promise_list.py", line 95, in _iterate
    None,
Zahlii commented 4 years ago

Is there any update on this or any way to help out? This is a critical issue since we are using Promise for job scheduling in production, and every once in a while this error comes around and forces us to re-run