pyowm icon indicating copy to clipboard operation
pyowm copied to clipboard

Support for async API calls

Open csparpa opened this issue 7 years ago • 7 comments

This would leverage Python 3.5's async/await features

API calls could just be async functions (aka coroutine functions) that pyowm returns and then get executed on an eventloop provided by client code

note: asyncio is part of the python std library only from 3.5 so 3.4 doesn't feature it (but asyncio can be imported as an external dependency)

Design solution

Make PyOWM 2.x sync functions a "sub-case" of async functions as stated here: https://stackoverflow.com/questions/53521716/enhance-synchronous-software-api-to-allow-asynchronous-consuming/53523001#53523001

csparpa avatar Apr 13 '18 15:04 csparpa

Take a look here for sync/async library calls handling: https://hackernoon.com/controlling-python-async-creep-ec0a0f4b79ba

csparpa avatar Nov 26 '18 07:11 csparpa

This is something I'd be interested in. Any specific reason it's now wontfix?

Harmon758 avatar Feb 14 '22 21:02 Harmon758

@Harmon758 No user interest so far.. and then you shouted ;-) I don't want to rule this feature out if it eventually proves useful !

csparpa avatar Feb 14 '22 21:02 csparpa

I'll throw my hat into the game, I am interested as my bot I plan on using OWM with is already async.

y2kbadbug avatar Nov 14 '22 03:11 y2kbadbug

@csparpa I personally would appreciate if you mind reopening this

aitorllj93 avatar Feb 19 '23 18:02 aitorllj93

@aitorllj93 @y2kbadbug @Harmon758 open again :)

Are you able to collaborate on this?

csparpa avatar Feb 19 '23 18:02 csparpa

So currently I implemented this on my own vanilla script using Python Treq to make the asynchronous calls. It is written on top of Twisted.

https://pypi.org/project/treq/

This might not be ideal for this project as the level of dependencies it can add, but when I get some free time I'll be happy to poke at a solution for this project.

y2kbadbug avatar Feb 20 '23 20:02 y2kbadbug