ably / ably-python

Python client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
49 stars 24 forks source link

Feature request: synchronous API variant #532

Closed owenpearson closed 11 months ago

owenpearson commented 1 year ago

Create a synchronous API variant so that users upgrading from <= 1.1 can do so without having to use the newer asyncio APIs.

sync-by-unito[bot] commented 1 year ago

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3862

sacOO7 commented 1 year ago

unasync requires use of setup.py file. Alternative way to do it in poetry itself -> https://stackoverflow.com/questions/60073711/how-to-build-c-extensions-via-poetry

sacOO7 commented 1 year ago

Link to internal conv - https://ably-real-time.slack.com/archives/C030C5YLY/p1695733725858389 Low level asynios eventloop apis -> https://docs.python.org/3.7/library/asyncio-eventloop.html High level task and coroutines build on top of asyncio eventloop -> https://docs.python.org/3.7/library/asyncio-task.html#asyncio.run

sacOO7 commented 1 year ago

Related links - run_until_complete => https://gist.github.com/phizaz/20c36c6734878c6ec053245a477572ec https://www.joeltok.com/posts/2021-02-python-async-sync/

run_coroutine_threadsafe => https://github.com/xloem/async_to_sync/blob/master/async_to_sync/__init__.py

https://bbc.github.io/cloudfit-public-docs/asyncio/asyncio-part-5.html from https://bbc.github.io/cloudfit-public-docs/

sacOO7 commented 1 year ago

https://superfastpython.com/threadpoolexecutor-wait-vs-as-completed/

sacOO7 commented 1 year ago

https://dev.to/mervynlee94/multi-threading-vs-event-loop-in-python-1h4h

sacOO7 commented 1 year ago

Use of multithreading for sync variant APIs will be avoided as per https://github.com/ably/ably-python/issues/534. There's an explicit requirement in the spec to use shared active fallback for HTTP requests, so the use of multithreading will create an overhead to manage active fallback ( same question raised at https://github.com/ably/ably-python/issues/531#issue-1901588285)

sacOO7 commented 1 year ago

Update documentation as a part of -> https://github.com/ably/ably-python/issues/530

sacOO7 commented 1 year ago

There's one more unasync implementation -> https://github.com/alex-sherman/unsync. Checking usage for the same.