syrusakbary / promise

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

Question: compatibility with asyncio's event loop? #6

Closed bevensteven closed 7 years ago

bevensteven commented 8 years ago

Hi,

Great module you got going on! I am attempting to make Python function identically to NodeJS as part of a personal project. Currently, I am using your Promises in a fashion that follows A+ but still have some trouble understanding how this module would interact with an asyncio event loop.

Does the event loop recognize when a Promise is fulfilled - similarly to how an asyncio.Future is given a result (via set_result) and marked as done?

If you have time, a toy example implementation of using your Promises with the asyncio event loop (mimicking Node's event loop) would help a lot.

Thanks!

syrusakbary commented 7 years ago

Yep, you can safely use Promise in asyncio as if you were using couroutines or Futures :)

It's also tested :) https://github.com/syrusakbary/promise/blob/master/tests/test_awaitable_35.py