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

usayncio: TypeError: exceptions must derive from BaseException #268

Open
larsks opened this issue Apr 4, 2018 · 2 comments
Open

usayncio: TypeError: exceptions must derive from BaseException #268

larsks opened this issue Apr 4, 2018 · 2 comments

Comments

@larsks
Copy link

larsks commented Apr 4, 2018

I have written some code that uses the asyncio module. The entrypoint point to my code looks like this:

try:
    control.main()
except KeyboardInterrupt:
    pass
except Exception as exc:
    sys.print_exception(exc)
    print('* resetting in 10 seconds')
    time.sleep(10)
    machine.reset()

And control.main looks like:

def main():
    [...]

    try:
        loop.run_forever()
        loop.close()
    finally:
        for task in tasklist:
            task.close()

I just upgraded to the version in micropython-lib as of 9e21d6e, and now when I interrupt my code with ^C I see the following error:

Traceback (most recent call last):
  File "snakecharmer/main.py", line 10, in <module>
  File "snakecharmer/control.py", line 52, in main
  File "uasyncio/__init__.py", line 246, in start_server
TypeError: exceptions must derive from BaseException

That seems to correspond to the following line in uasyncio/__init__.py:

yield IORead(s)

What's going on here?

@devbis
Copy link

devbis commented Dec 28, 2018

Run into the same issue on the lastest micropython-lib but without interrupting the code with ^C.
Possibly, some internal exceptions in _socket lib while I read from reader

await reader.readline()

Had to catch this weird exception to run my code

@jonnor
Copy link

jonnor commented Aug 25, 2024

Is this still a problem with the latest MicroPython ?

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