Comments (9)
Would be great if you could share your design idea in more detail, and what changes should be taken to make this feature possible.
from sdk-for-python.
We can use aiohttp instead of requests to make client module async. By doing this we can make call
method an awaitable coroutine and this will propagate all the way up to other classes like Database, Health, etc, and make it asynchronous.
What will be the benefits?
Users can start multiple requests concurrently.
Ex:
db = Database()
await db.create_collection(...) # req1
await db.create_collection(...) # req2
Here, both req1 and req2 will run concurrently instead of sequentially.
from sdk-for-python.
@Niraj-Kamdar is there a way to make call method an awaitable natively without using any 3rd party dependency? Also what about backward compatibility after this change?
from sdk-for-python.
Yes, we can make call
method an awaitable by running it in threadpool but this solution has a con - by default, it will only run 5 tasks concurrently while native asynchronous library like aiohttp
can run many tasks concurrently and all tasks run co-operatively instead of pre-emptively. For example, if I spawn 10 tasks concurrently when the underlying method is running on threads it will only run 5 tasks at a time, and when they complete it will start the remaining 5 tasks. In the case of the native async library like aiohttp
, all tasks will spawn concurrently.
I believe concurrency is important to scale application but some people may still want a normal synchronous version of SDK maybe because their application hasn't designed to run concurrently. So, for backward compatibility, we have to consider the following options:
- Create a separate async SDK.
- Create async methods with "a" prefix in the same SDK. For example:
call
will beacall
. Cpython has done this with__enter__
and__exit__
methods and they call it__aenter__
and__aexit__
when used asynchronously.
from sdk-for-python.
@christyjacob4 is this relevant? Please close if not.
from sdk-for-python.
Just my 5ยข: might want to look into https://www.python-httpx.org/, which supports both sync and async, while still retaining Requests-like API. Not sure if it would be possible to not duplicate the wrapper, but at least it will be one external dependency vs two (requests + aiohttp).
from sdk-for-python.
@notpushkin is this something you'd like to explore ?
from sdk-for-python.
This issue was opened 2 years ago & still not implemented. I highly support @Niraj-Kamdar 's idea. Please let us know if this is in the plan. And I would love to contribute if need any help.
from sdk-for-python.
Latest PR on this: appwrite/sdk-generator#453
from sdk-for-python.
Related Issues (20)
- Improved code snippets for debugging HOT 2
- While creating team the logged in user is not getting registered as owner. HOT 9
- Issue creating a file HOT 7
- Upgrade our issue templates to use GitHub issue forms โ๏ธ HOT 7
- SSL Verification is Off by Default HOT 1
- ๐ Bug Report: HOT 1
- ๐ Feature: Type hints HOT 10
- ๐ Bug Report: Python SDK - Querying with a boolean value leads to " Query type does not match expected: boolean" HOT 9
- ๐ Feature: use fstring instead str.replace() ? HOT 9
- ๐ Bug Report: library not working around `http` and only works for `https` HOT 6
- ๐ Feature: Console API HOT 1
- ๐ Bug Report: `Query.orderDesc` and `Query.orderAsc` not working. HOT 2
- ๐ Bug Report: Can't filter by DateTime
- ๐ Feature: use linting tools (pre-commit) HOT 8
- ๐ Feature: use type hints
- ๐ Documentation: Mistake in code snippets in getting started guide HOT 18
- ๐ Documentation: HOT 1
- ๐ Bug Report: AttributeError: type object 'Query' has no attribute 'orderDesc' HOT 2
- ๐ Documentation: Updating Readme HOT 3
- ๐ Bug Report: Start With Python Tutorial fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-for-python.