-
Notifications
You must be signed in to change notification settings - Fork 16
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
"no module named 'usocket'" on Raspberry Pico W #35
Comments
CircuitPython doesn't have |
I believe that From what I can see This is my attempt at minimal repro without using Microdot: import asyncio
async def main():
async def serve(reader, writer):
pass
await asyncio.start_server(serve, "0.0.0.0", 80)
asyncio.run(main()) 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 |
You're right, we should change this line:
|
Also true, but in my case I think it's about the server part:
|
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 |
The same applies to the |
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 |
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! |
.... this issue is still relevant and affects probably all ports. I was making a switch from Micropython to Circuitpython, but tripped on:
crashes with
Major bummer 😞 , given that according to docs |
I believe it really should be fixed. For me, I wasn’t able to continue with micropython because of it. Which is a double bummer because I’ve had to backport so so many drivers. I hope this can be fixed soon, it will make embedded servers much more viable on micropython.
Thank you!
Regards,
Max Carlson
… On May 8, 2024, at 11:10 PM, Jev Kuznetsov ***@***.***> wrote:
.... this issue is still relevant and affects probably all ports. I was making a switch from Micropython to Circuitpython, but during testing running:
asyncio.create_task(asyncio.start_server(serve_client, "0.0.0.0", 80))
crashes with
Traceback (most recent call last):
File "asyncio/core.py", line 261, in run_until_complete
File "asyncio/stream.py", line 225, in start_server
ImportError: no module named 'usocket'
Major bummer 😞 , given that according to docs start_server should be supported. Shouldn't this be in test coverage?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Just to clarify @mcarlson, I think you mean CircuitPython here? I've been using microdot on MicroPython for years with no issue whatsoever... |
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. |
Yes, sorry I misspoke - I meant CircuitPython. I’ve had to stick with Micropython so I have asynchronous http support and my embedded server leaves time for other tasks to run. It’s quite amazing what the pico can do!
Regards,
Max Carlson
… On May 9, 2024, at 8:16 AM, Matt Trentini ***@***.***> wrote:
I believe it really should be fixed. For me, I wasn’t able to continue with micropython because of it.
Just to clarify @mcarlson, I think you mean CircuitPython here? I've been using microdot on MicroPython for years with no issue whatsoever...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
You mean rebuilding CP? Could you please link to your PR? |
Please send a link to the PR/branch/commit and I’d be happy to give this a test! I’d so love to be using CircuitPython… Thank you!
Regards,
Max Carlson
… On May 9, 2024, at 5:47 PM, Jev Kuznetsov ***@***.***> wrote:
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.
You mean rebuilding CP? Could you please link to your PR?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I just mean changing the names in this library. Just get the Python (not .mpy) version of this library and edit it so the import names match. e.g. change |
@dhalbert - ... couple of hours further it does not seem that simple. I replaced
It helpled a bit - the server could be started. only to crash later with
BTW, there is more smelly stuff in
It does not not feel right to keep hacking further without proper test cases in place. That would not be trivial to do, because we'd need something like descent mocks first on a unix port. |
Would https://github.com/micropython/micropython/blob/master/tests/run-tests.py be useful as the basis for a testing framework?
Regards,
Max Carlson
… On May 10, 2024, at 6:39 AM, Jev Kuznetsov ***@***.***> wrote:
@dhalbert - ... couple of hours further it does not seem that simple.
I replaced import usocket as socket in start_server by this:
import wifi
import socketpool
socket = socketpool.SocketPool(wifi.radio)
It helpled a bit - the server could be started. only to crash later with
Traceback (most recent call last):
File "/lib/asyncio/core.py", line 261, in run_until_complete
File "webserver.py", line 16, in serve_client
File "/lib/asyncio/stream.py", line 100, in readline
AttributeError: 'Socket' object has no attribute 'readline'
BTW, there is more smelly stuff in stream.py , like
from uerrno import EINPROGRESS # there is no `uerrno` in circuitpython
import socketpool as socket # these are not equivalent.
It does not not feel right to keep hacking further without proper test cases in place. That would not be trivial to do, because we'd need descent mocks first on a unix port.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Any path forward here? |
I think there are two things going on here:
If your goal is to just have an HTTP server, then there is https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer, but it is not async. |
We are just starting to merge MicroPython v1.21 through v1.23 into CircuitPython. A side effect of this will be updating this asyncio library from the version that is in https://github.com/micropython/micropython/tree/master/extmod/asyncio. I talked with @tannewt briefly about this in discord. We need |
I would love it if there was because circuitpython is so appealing in so many ways!
Personally, I’ve had to stick with micropython because of these issues. I need an embedded web server!
Regards,
Max Carlson
… On Jul 12, 2024, at 2:19 AM, Sveinung Kval Bakken ***@***.***> wrote:
Any path forward here?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Have you looked at https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer, or do you need the async support? |
Yes, I need the async support. Otherwise I can’t easily use sensors, control lighting etc. etc.
Regards,
Max Carlson
… On Jul 12, 2024, at 11:09 AM, Dan Halbert ***@***.***> wrote:
I need an embedded web server!
Have you looked at https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer, or do you need the async support?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I'm doing several tasks, for sensors etc, but anything more than a second or so between each check if the socket the web experience seems very bad. There's async support in the socket itself in MP, but the same doesn't seem present in CP. See the socket callback registered here. https://github.com/orgs/micropython/discussions/12219#discussioncomment-6713393 The code to register, check and invoke these subscriptions are not present in CP's socket.c as far as I can tell. I'm getting an exception when trying to run the same code as this only expects integer or buffer as 3rd arguments. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Any progress on this? Have others found a work around? I attempted to create an async driven TCP server using the lower level aspects of pythons async IO. I was unsuccessful. As others have mentioned, not all CPython async functionality has been ported to CircuitPython/MicroPython. I have custom python infrastructure around sensor gathering from various Weather Stations and indoor sensor "sites" As a workaround, I'm going to code up a TCP Server with a timeout on socket.accept() when the timeout occurs I'll go poll the sensors (temp, humidity, etc) and then loop back to accept. It'll work just fine, but the async solution would have been nice and succinct. |
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:
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!
The text was updated successfully, but these errors were encountered: