iamkubi / pydactyl

Python wrapper for the Pterodactyl Panel API
MIT License
69 stars 21 forks source link

Add async support #59

Open iamkubi opened 2 years ago

iamkubi commented 2 years ago

This would only be feasible if it leaves the existing behavior intact as synchronous calls. There are ways to write the code as async and have a wrapper that generates a synchronous version. This could potentially be refactored so that pyadctyl exposes get_servers() and async_get_servers() without impacting the existing behavior.

Some relevant links

https://discuss.python.org/t/how-can-async-support-dispatch-between-sync-and-async-variants-of-the-same-code/15014/14
https://gist.github.com/blink1073/969aeba85f32c285235750626f2eadd8
quswadress commented 1 month ago

Hi, @iamkubi. I made a partially working version with asynchronous calls, and I have a couple of questions for you.

Firstly, what should the documentation look like for synchronous functions? Should it just copy-paste from asynchronous methods or refer to them or something else? The same question I have for tests: if synchronous versions will call asynchronous ones, then it is not necessary to test asynchronous ones directly, am I right?

Or how will synchronous calls work? You can call asynchronous in a new(or existing) loop/thread/etc. But you can just use the existing synchronous requests.Session(or httpx.Client) and don't bother with it. Also, is there no problem here if I use httpx library for asynchronous requests?