Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async wrapper #23

Open
eve-alt opened this issue Aug 25, 2020 · 12 comments
Open

async wrapper #23

eve-alt opened this issue Aug 25, 2020 · 12 comments

Comments

@eve-alt
Copy link

eve-alt commented Aug 25, 2020

Howdy there!

Originally posted by @Tmpod in #7 (comment)

Sry for posting on this closed issue but I've been looking for an async fork of this and I haven't found anything. So, since I'm quite experienced with the async framework and I've already done another async API wrapper (for Hypixel), I'd like to do that. I will start working on it as soon as I can and I'll post a message in this thread once it's done/usable.

Is that OK?

hi, as I was reading thru issues I saw ur reply and thought that hey, a year already passed and was just thinking if it was released already and I didn't know about it. I also tried googling pokebase-async and didn't see anything that I was looking for so, I'd like to ask if the async wrapper will be really a thing.

@Naramsim
Copy link
Member

@eve-alt. feel free to implement it. What would be the benefit of having an async wrapper? That you could include in async Python projects?

I'm not really familiar with async in Python. It seems it was invented to speed up an application and to not have blocking threads, am I right?

Anyway, once your done, we can reference your wrapper in our readme/website. Or if you want we can include it under the PokeAPI org.

@GregHilmes
Copy link
Collaborator

That sounds wonderful eve-alt! Will you be submitting this as an update to pokebase (so that users who want a python wrapper can download pokebase and then choose if they want synchronous/asynchronous operation), or will this be a separate module (like pokebase-async or whatever you want to name it)?

@eve-alt
Copy link
Author

eve-alt commented Aug 26, 2020

hi, i think you misunderstood what i said, i just referenced another command made by someone else as i was asking if he already released it since a year has passed already.

@Naramsim
Copy link
Member

Oh, Now I get it! I'll format your issue properly.

To answer your question: no nothing has been released. But feel free to do it, if you got inspired by our excitement 😸

@C-Garza
Copy link
Member

C-Garza commented Aug 30, 2020

I decided to try and practice some python and attempt to make the async wrapper. I made a branch in my fork here.

I didn't change any original code, so you can still use it as synchronous code, and instead made the functions/classes as async. It seems to work, although I don't know much about python asynchronous testing so I haven't made any tests for it 😅.

You can try it out by starting an event loop and calling the async functions, like so:

loop = asyncio.get_event_loop()

async def main():
    charmander = await pb.async_pokemon('charmander')
    charmander.height

loop.run_until_complete(main())

I hope one of you can give it a try and let me know what you think 😄.

@Naramsim
Copy link
Member

Not a Python expert also on my side. I'll give it a try if @Kronopt cannot take a look at it :)

@Kronopt
Copy link
Member

Kronopt commented Aug 30, 2020

I just brushed over the code and it looks good, @C-Garza!
I didn't test it though.

I just have one comment: This way you have the requirements for both implementations of pokebase (async and regular) on the same package. That might not be ideal.

To test aiohttp requests you could try aioresponses.

@C-Garza
Copy link
Member

C-Garza commented Aug 31, 2020

Yeah I quickly realized that I would basically have to keep separate async versions of the code, but kept them in the same files for now. So @Kronopt, would you suggest that async changes be added as a separate module like pokebase-async like @GregHilmes mentioned above?

I guess I have to learn some async python testing now 😅.

@Naramsim
Copy link
Member

Hi boys, in case you are wondering, we can have a separate project nested in the PokeAPI org. We can use PokeAPI/pokebase-async or a completely new name PokeAPI/{you decide}.

I'd opt for a new one.

@Kronopt
Copy link
Member

Kronopt commented Aug 31, 2020

@C-Garza a separate module would be best yes, in my opinion

@beastmatser
Copy link

Hi! I just wanted to tell that I made an async wrapper for the pokeapi, you can find it here.

@Tmpod
Copy link

Tmpod commented Oct 2, 2021

Howdy there!

Originally posted by @Tmpod in #7 (comment)
Sry for posting on this closed issue but I've been looking for an async fork of this and I haven't found anything. So, since I'm quite experienced with the async framework and I've already done another async API wrapper (for Hypixel), I'd like to do that. I will start working on it as soon as I can and I'll post a message in this thread once it's done/usable.
Is that OK?

hi, as I was reading thru issues I saw ur reply and thought that hey, a year already passed and was just thinking if it was released already and I didn't know about it. I also tried googling pokebase-async and didn't see anything that I was looking for so, I'd like to ask if the async wrapper will be really a thing.

Hi! Sorry, I ended up not going very far with it because I stopped working on the project that needed the wrapper... I should have posted an update on that issue, apologies :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants