Open
Description
Hi,
I'm trying to use this package in order to run an HTTP Server (Microdot) concurrently with other tasks on Raspberry Pico W.
It's failing for me with:
Traceback (most recent call last):
File "<stdin>", line 42, in <module>
File "microdot_asyncio.py", line 320, in run
File "asyncio/core.py", line 297, in run
File "asyncio/core.py", line 261, in run_until_complete
File "asyncio/core.py", line 246, in run_until_complete
File "microdot_asyncio.py", line 278, in start_server
File "asyncio/stream.py", line 226, in start_server
ImportError: no module named 'usocket'
Am I doing something totally unsupported yet, like maybe only some subset of CircuitPython devices have usocket
?
I know that sockets generally work if I use socketpool
for screating sockets, so maybe I'm really looking after #4 ?
I'd appreciate any pointers!
Metadata
Metadata
Assignees
Labels
No labels
Activity
dhalbert commentedon Nov 20, 2022
CircuitPython doesn't have
usocket
, but you can usesocketpool
. It looks like themicrodot
server is written for MicroPython, not CircuitPython, but you could modify it.noinskit commentedon Nov 20, 2022
I believe that
usocket
is called from withinAdafruit_CircuitPython_asyncio
directly.From what I can see
microdot
server is only usingasyncio
and itsstart_server
method, which doesn't sound like depending on MicroPython.This is my attempt at minimal repro without using Microdot:
Note that I'm not really initializing wifi in my example, but since I would not be able to pass the initialized socket pool to asyncio anyway, it wouldn't help.
The result:
I'll admit that in the meantime I also tried to make a
socketpool.SocketPool
object pretend to be theusocket
module for the sake ofasyncio
, but it's currently failing for me onsocket
objects from there not having asetsockopt
method.dhalbert commentedon Nov 20, 2022
You're right, we should change this line:
Adafruit_CircuitPython_asyncio/asyncio/stream.py
Line 152 in a044da1
noinskit commentedon Nov 20, 2022
Also true, but in my case I think it's about the server part:
Adafruit_CircuitPython_asyncio/asyncio/stream.py
Line 226 in a044da1
chrismurf commentedon Nov 29, 2022
This bit me tonight with the AdaFruit ESP32 Feather V2 as well, so for anybody new and googling - it's not specific to the Raspberry Pico W at all.
I believe this will also affect
open_connection
calls.jordonsc commentedon Sep 25, 2023
The same applies to the
uerrno
import on the line above.byzantic commentedon Jan 30, 2024
I'm having the same issue here, except that I am trying to use the Wiznet W5500-EVB-Pico.
Now, interestingly, this does have a
socket
implementation already (adafruit_wiznet5k.adafruit_wiznet5k_socket
) .. but how would I set upasyncio
to use that instead?mcarlson commentedon Feb 29, 2024
This bit me also, which is too bad because the official circuitpython story for not supporing interrupts/multithreading (which I get!) is to use asyncio for applications where you need to do more than one thing at a time. For me, that means going back to micropython as I'm building 'headless' apps that rely on microdot/being able to run an async server.
Not super stoked because the story for not having interrupts in circuitpython is is 'use asyncio' per https://learn.adafruit.com/cooperative-multitasking-in-circuitpython-with-asyncio/overview
But, the circuitpython asyncio doesn't work with microdot because they don't implement start_server. So I'm blocked... Please fix this!
sjev commentedon May 8, 2024
.... this issue is still relevant and affects probably all ports. I was making a switch from Micropython to Circuitpython, but tripped on:
asyncio.create_task(asyncio.start_server(serve_client, "0.0.0.0", 80))
crashes with
Major bummer 😞 , given that according to docs
start_server
should be supported. Shouldn't this be in test coverage?mcarlson commentedon May 8, 2024
mattytrentini commentedon May 9, 2024
Just to clarify @mcarlson, I think you mean CircuitPython here? I've been using microdot on MicroPython for years with no issue whatsoever...
dhalbert commentedon May 9, 2024
Have any of you tried the source version and just fixed the import names? I started a PR to do that. There are only a few lines to change. It might still be the case that something doesn't work.
mcarlson commentedon May 9, 2024
19 remaining items