zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
365 stars 369 forks source link

Async support (asyncio, Twisted, etc.) #483

Open glyph opened 6 years ago

glyph commented 6 years ago

I'd love a version of call_on_each_event that would not block, and instead register a callable with a reactor.

This could probably be combined with fairly general / framework agnostic async support by having the existing implementation be converted into a coroutine which awaits different kinds of things (treq requests in the Twisted case, synchronously-returning coroutines that just call requests in the default / existing case, aiohttp Futures for asyncio).

neiljp commented 6 years ago

Would it be accurate to describe this as asking for non-blocking support in the python API?

timabbott commented 6 years ago

I think @kcr's https://github.com/1ts-org/snipe/blob/master/snipe/zulip.py#L127 has some work that could be borrowed/extracted for this (since snipe is a Python cross-protocol IM client that uses asyncio).

glyph commented 6 years ago

Would it be accurate to describe this as asking for non-blocking support in the python API?

Yep; any form of modern asyncio/tornado/Twisted support could ultimately be converted into this, and could therefore close this ticket.