New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async and httpx support #131
Comments
Thank you and welcome! Async support has been in the back of my mind since discovering PyFy. It would certainly be a good feature to add. Initially I thought that it wouldn't have that much use, but would you like to tell me more about your application? I'd love to hear what sorts of things its good for, especially since I'm not that experienced with async itself. What do you have in mind in terms of annotations? They are almost everywhere in our code already. The most significant problem is with documentation (#109). |
About annotations - it was first assumption, I glanced at class ExternalURL:
spotify: str My pet-project is not working for about a year, but what it was doing is this:
Year ago I started experiencing problems with backend workers timeouts, since I was using async web framework ( I see you are using |
Frontend is still up and running - https://music.neigor.me/ |
If I recall, that sort of class existed at some point. But I took it out, maybe because there were other external URLs, but I don't quite remember. I'll have to look at it once more. That's a cool application! I'll investigate httpx support too. Let me get back to you. |
At first glance Httpx seems like a great library! It even has a client object for automatically appending base URLs. Cool. And they are planning to release 1.0.0 in this April. From what I've understood, the real power of Async programming is the ability to make concurrent requests. Now that's rather obvious, but correct me if I'm wrong: with sequential applications using Async it is essential to gather many requests for execution at once and await them, rather than making one request, then some code, then another request. Then servers with Async are another thing. So if we were to implement an Async client, given my inexperience, I'd like to clarify some things. If you can help, great, if not then I'll dive in deeper myself.
|
Concurrent requests - yes, async gives ability to make them in parallel, because async should not block execution as it blocks it with threads. When you are writing async code - you should go full async, otherwise libraries like So we can't use
Last question I did not get, what do you mean? Sessions and keepalive should work the same as for If there is anything else you need to know - let me know |
Yes, these were exactly what I was looking for, thanks a bunch! With regards to the last question, I'm simply not aware of how the keepalive is implemented and how requests are delivered in HTTP. The fact that it can be used in async as well is enough for me. So here's what I'm thinking. We could start developing the idea of an async client using Httpx and implementing some simple version. Then we should think about what it means for Senders that wrap around I'll take the ball first, implement something and make a PR so we can discuss the practicalities more. It may take a while though. Let's see what we can make out of this! |
I could try to make some simple proof of concept, but I will have time only on Friday and weekend this week |
The mentioned PR will provide initial support for Async and Httpx, but not break compatibility. Some additional concerns will remain, and they are very much worth considering when we think about releasing 2.0.
|
Ah, I just saw your comment. I don't think I'm experienced enough with async to give you advice, but using only |
@felix-hilden my thoughts:
|
Thanks for your input! I meant dividing them up into submodules for just for the sake of refactoring and cleaning things up. The senders would then be imported back to the top level of sender. |
We can't refactor the sender module yet. But I have an idea for an improvement. It would break setting defaults though. This is beyond this issue, but I'll open up another one based on this for Tekore 2.0 when this is closed. And one for Httpx exclusivity too. |
Hey, just found this library - great work!
100% tests coverage is great and 100% type-hints (but not just
dict
s andlist
s) and async support would be even better 馃槃Did not found a project that has all three, so I written own wrapper for my pet-project with those requirements.
But it has only 3 endpoints (user/me, player/currently-playing and OAuth2.0 methods) and I don't want to invent my own wheel (API wrapper), can I help with annotations and async support?
The text was updated successfully, but these errors were encountered: