syrusakbary / promise

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

How thread safe are promises? #68

Closed dongryphon closed 4 years ago

dongryphon commented 5 years ago

After reading through the source for some time I do not see any use of locks (like the imported and ignored from threading import RLock) to protect one thread adding a callback to a promise instance from another thread that is resolving/rejecting that promise...

So is such use of a promise invalid or does it work because of the GIL? ... or something else?

Thanks for the awesome code!

dongryphon commented 5 years ago

Would really appreciate even a couple words of wisdom on this...

dongryphon commented 5 years ago

Is this the proper place to ask questions?

jtschulz commented 5 years ago

I am encountering some weirdness with heavy queries seemingly randomly failing and it is only reproducible when we're making multiple concurrent requests, so we're starting to wonder if this is related. We're still investigating, so it could be totally unrelated. I am however curious if anyone else has had similar experiences.

chroth commented 5 years ago

@PepperTeasdale It sounds like your issue is related to https://github.com/syrusakbary/promise/issues/57

jtschulz commented 5 years ago

We could probably close this issue then, since the answer seems to be "no" and there are duplicate issues where people are getting errors from the threading issues. Unclear if there is any roadmap here or on graphene to fix these issues or supercede this project :(

syrusakbary commented 4 years ago

The PR #81 has been merged. Promises should be now thread-safe in Promise 2.3.0