← index #5870Issue #6472
Related · medium · value 1.603
QUERY · ISSUE

extmod/uasyncio: add serve_forever()?

openby belyalovopened 2020-04-06updated 2020-04-07
extmod

Official example from python documentation:

async def main():
    # Get a reference to the event loop as we plan to use
    # low-level APIs.
    loop = asyncio.get_running_loop()

    server = await loop.create_server(
        lambda: EchoServerProtocol(),
        '127.0.0.1', 8888)

    async with server:
        await server.serve_forever()


asyncio.run(main())

Micropython's Server class already has support for async with, but lacks convenient method serve_forever.

Do you think it is make sense to add it?

CANDIDATE · ISSUE

`Loop.run_forever()` doesn't run forever (?)

closedby ShenTengTuopened 2020-09-23updated 2026-03-17
extmod
  • firmware: esp32-idf4-20200906-unstable-v1.13-4-g3ff707927.bin

testing code:

from uasyncio import get_event_loop
loop = get_event_loop()
try:
  print("run_forever")
  loop.run_forever()
finally:
  loop.stop()
  loop.close()

On CPython, it will run forever, but not on MicroPython for me.
Isn't its implementation equivalent to the CPython implementation?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied