aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python
https://docs.aiohttp.org
Other
15.15k stars 2.02k forks source link

Aiohttp implementation for MicroPython #6584

Open AmirHmZz opened 2 years ago

AmirHmZz commented 2 years ago

Is your feature request related to a problem?

There's lack of a suitable async http client and server for MicroPython.

Describe the solution you'd like

Aiohttp can be implemented for MicroPython language to be used in many IOT projects.

Describe alternatives you've considered

There are some tiny - non developed projects but they are full of bugs.

Related component

Server, Client

Additional context

MicroPython supports asyncio and I think some memory optimization stuff should be done.

Code of Conduct

Dreamsorcerer commented 2 years ago

I'm sure nobody here is going to have the time and motivation to look at this. But, if you can get it working and have the tests running in CI, then it could be considered. I'm a little concerned how many little hacks might be needed to make it work though. I can see that asyncio is not included, so you would have to add a bunch of:

try:
    import asyncio
except ImportError:
    import uasyncio as asyncio

I imagine there are more things that might make it awkward and not worth doing.

vrcoelho commented 2 years ago

What about https://github.com/micropython/micropython-lib/tree/master/micropython/uaiohttpclient?

Dreamsorcerer commented 2 years ago

What about https://github.com/micropython/micropython-lib/tree/master/micropython/uaiohttpclient?

What about it? Maybe useful for some people, but with <100 lines of code, it's hardly an implementation of aiohttp or anything that can be transferred into aiohttp itself.

ds-digid commented 1 year ago

Hi, I am writing on an IoT Project that transfers data over http. I am looking for a way to speed things up as the requests library is a blocking function that slows down my entire system (ESP32 with attached sensors were data is gathered in asyncio tasks). Is this feature request still open, or are there some other libraries that might be usefull for async data transfer via http?

Dreamsorcerer commented 12 months ago

Nobody else has looked at it, my comment is still the same. It could be included if the changes are fairly small (see, for example, #7803). When I looked it seemed like it would probably need some rather invasive changes to work with their uasyncio thing, however, looking again today, it looks like they've added a proper implementation of asyncio, which might makes things a lot easier.

AmirHmZz commented 12 months ago

After v1.21 release uasyncio has been renamed to asyncio. Support for SSLContext was added too in https://github.com/micropython/micropython/commit/e8a4c1dd537c7ccfba92936c6eee9d5cf529be9e .