adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.11k stars 1.22k forks source link

Add support for async wifi.radio.connect #6000

Open terussell85 opened 2 years ago

terussell85 commented 2 years ago

With the recent introduction of asyncio, it has allowed great simplification of simultaneous code loops for things like animations or playing audio.

However, the interface to wifi.radio.connect is still fully blocking. I might be missing other options, but as far as I can tell, this makes doing things like animations or sounds impossible while wifi connections are in progress. At least for singular integrated chips (not using coprocessors).

Ideally I'd be able to await wifi.radio.connect so that I can release the thread for NeoPixel animations or other items.

dhalbert commented 2 years ago

I am working on async aspects of this, at first doing some kind of async version of adafruit_requests. We may need to add non-blocking primitives to radio: I haven't yet looked at that level, still choosing the API for the user library.

jake commented 2 years ago

just curious if there's been any progress on async versions of wifi.radio.connect or adafruit_requests? or if there's any workarounds for making async networking requests.

dhalbert commented 2 years ago

I started a fork in the adafruit_requests library: https://github.com/dhalbert/Adafruit_CircuitPython_Requests/tree/async. I think someone used it successfully (perhaps with some changes), even though I hadn't even tried it in any way yet.

shn-dev-1 commented 1 year ago

Any update on making this non-blocking per the OP?

codegrue commented 1 year ago

Adding my vote as well. Blocking on request is one of the core use cases for async.

luto commented 1 year ago

Is anyone interested in working on this as well as an async API for adafruit_requests? I would like to sponsor the work. Mention me here or ping me via email (see profile).

Snipeye commented 5 months ago

Adding my vote - want to run some idle animations while the radio is connecting, etc.