Skip to content
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

shutdown() tries to access non-existent attribute "cancel" on uasyncio module #46

Open
phlipped opened this issue Oct 26, 2021 · 2 comments

Comments

@phlipped
Copy link

asyncio.cancel(self._server_coro)

Board: esp8266, generic nodeMCU dev board
Micropython: 1.17 (esp8266 port), with frozen modules tinyweb and logging

I'm trying to perform the "shutdown" procedure as per instructions in the reference material for the webserver class, i.e.

async def all_shutdown():
    await asyncio.sleep_ms(100)

try:
    web = tinyweb.webserver()
    web.run()
except KeyboardInterrupt as e:
    print(' CTRL+C pressed - terminating...')
    web.shutdown()
    uasyncio.get_event_loop().run_until_complete(all_shutdown())

When I run my server then hit Ctrl-C, I get:

Traceback (most recent call last):
  File "main.py", line 30, in run
  File "tinyweb/server.py", line 689, in shutdown
  File "uasyncio/__init__.py", line 1, in __getattr__
AttributeError: cancel
@robartsd
Copy link

Correct, according to the latest documentation uasyncio has no cancel() function at the module level. I think what is intended is to call the cancel() method of the Task class; however, I don't see that the code is saving references to the task instances returned calls to the loop .create_task() method.

@ClaasF
Copy link

ClaasF commented May 19, 2023

Is there some way to shut the server down then?

I'm trying to shut it down after receiving a request and currently I can't find any way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants