-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add uasyncio version of urequests (with patch) #550
Comments
Thanks @GM-Script-Writer-62850 -- this is neat and definitely supporting a more full-featured asyncio http client is something we need for MicroPython. I'm not sure adding an async version of I think the effort would be better spent turning this into a micro implementation of |
i did look at this one, but it did not look to support sending post data (massive deal breaker for my use case) |
|
Errr, umm, yes, that seems distinctly unimplemented. 🙄 |
i realized today i could also just make a non-blocking post request that will be delayed till my sleep call happens
Could combine this with my modded |
This is not a non-blocking post request. It's just a deferred post request that is still blocking. Your event loop will still pause while one HTTP request happens and there will only be one concurrent request. |
i know it is just deferred, i am just not sure it would be a good idea to do it truly non-blocking, in my use case this would max at 2 post request running at the same time the way my code is setup i have a entire 2 seconds to make post request w/out interfering with any other code execution at all (baring once a day events and a client actively connected) and this window will be followed by a 750ms window things to consider:
|
@GM-Script-Writer-62850 FYI, I am looking for an |
@bulletmark @GM-Script-Writer-62850 you may want to try this #752, just remove ..
reader, writer = await asyncio.open_connection(host, port, ssl=ssl)
... and it should work 👍🏼, e.g. import uaiohttpclient as aiohttp
import asyncio
async def fetch(client):
async with client.get("http://micropython.org") as resp:
assert resp.status == 200
return await resp.text()
async def main():
async with aiohttp.ClientSession() as client:
html = await fetch(client)
print(html.decode())
if __name__ == "__main__":
asyncio.run(main()) |
@GM-Script-Writer-62850 @Carglglz After removing that However, after failing with that earlier I went back to the standard |
@GM-Script-Writer-62850 BTW, you could actually remove the |
There is now a quite full featured HTTP client in |
Note that
|
|
Patch: urequests.zip
Attachment includes both before/after scripts of the current version of urequests as well as a
diff.patch
fileThis also includes a copy of this with the patch applied for issue #546
Using this test code shows my uasyncio urequests patch works
The text was updated successfully, but these errors were encountered: