You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know whether or not you need this, as it seems to be occurring because of known problematic generator usage, the original code was faulty and the advice given in the traceback does indeed fix the issue. However, trio said to report it, so here it is.
import trio
import trio_websocket # pip
import httpx # pip
async def _websocket():
async with trio_websocket.open_websocket_url('wss://echo.websocket.org') as w:
await w.send_message('hi !')
msg=await w.get_message()
print('Websocket responded', flush=True)
yield msg
async def main2():
async with httpx.AsyncClient() as httpclient:
await httpclient.get("https://example.com/")
print('Page responded', flush=True)
async for msg in _websocket():
raise NameError
trio.run(main2)
Python 3.9, Trio 0.18.0
When echo.websocket.org can be bothered to reply at all, there's a > 50% chance that the following traceback will occur:
[neil@localhost ~]$ python ./trio-error.py
/home/neil/.local/lib/python3.9/site-packages/trio/_core/_multierror.py:502: RuntimeWarning: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.
warnings.warn(
Page responded
Websocket responded
Traceback (most recent call last):
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 2185, in unrolled_run
runner.task_exited(task, final_outcome)
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1506, in task_exited
self.tasks.remove(task)
KeyError: <Task '__main__.main2' at 0x7f1fa8d23970>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/neil/./trio-error.py", line 21, in <module>
trio.run(main2)
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1923, in run
timeout = gen.send(next_send)
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 2230, in unrolled_run
raise TrioInternalError("internal error in Trio - please file a bug!") from exc
trio.TrioInternalError: internal error in Trio - please file a bug!
Exception ignored in: <function Nursery.__del__ at 0x7f1fa991d940>
Traceback (most recent call last):
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1055, in __del__
AssertionError:
Exception ignored in: <coroutine object Runner.init at 0x7f1fa8cf09c0>
Traceback (most recent call last):
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1613, in init
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 802, in __aexit__
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 914, in _nested_child_finished
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 896, in _add_exc
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_ki.py", line 159, in wrapper
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 681, in cancel
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 357, in recalculate
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1174, in _attempt_delivery_of_any_pending_cancel
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1156, in _attempt_abort
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_io_epoll.py", line 292, in abort
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_io_epoll.py", line 261, in _update_registrations
ValueError: I/O operation on closed epoll object
Exception ignored in: <function Nursery.__del__ at 0x7f1fa991d940>
Traceback (most recent call last):
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 1055, in __del__
AssertionError:
Exception ignored during finalization of async generator '__main__._websocket' -- surround your use of the generator in 'async with aclosing(...):' to raise exceptions like this in the context where they're generated
Traceback (most recent call last):
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_asyncgens.py", line 186, in _finalize_one
await agen.aclose()
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_ki.py", line 159, in wrapper
return fn(*args, **kwargs)
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 539, in __exit__
remaining_error_after_cancel_scope = self._close(exc)
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 476, in _close
scope_task = current_task()
File "/home/neil/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 2271, in current_task
raise RuntimeError("must be called from async context") from None
RuntimeError: must be called from async context
[neil@localhost ~]$
The text was updated successfully, but these errors were encountered:
I don't know whether or not you need this, as it seems to be occurring because of known problematic generator usage, the original code was faulty and the advice given in the traceback does indeed fix the issue. However, trio said to report it, so here it is.
Python 3.9, Trio 0.18.0
When echo.websocket.org can be bothered to reply at all, there's a > 50% chance that the following traceback will occur:
The text was updated successfully, but these errors were encountered: