Skip to content

KeyError in KqueueIOManager.process_events (TrioInternalError) #3500

Description

@james-emerton

We have a PySide6 (Qt) application using Trio in guest mode. We are occasionally seeing the error below:

Traceback (most recent call last):
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/trio/_core/_run.py", line 2765, in unrolled_run
    runner.io_manager.process_events(events)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/trio/_core/_io_kqueue.py", line 93, in process_events
    receiver = self._registered[key]
               ~~~~~~~~~~~~~~~~^^^^^
KeyError: (46, -2)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/dev/spire/spire-desktop/src/quicore/asyncio.py", line 142, in event
    event.fn()
    ~~~~~~~~^^
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/trio/_core/_run.py", line 1752, in guest_tick
    self.done_callback(Error(exc))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/dev/spire/spire-desktop/src/quicore/asyncio.py", line 130, in _done_callback
    result = outcome_.unwrap()
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/outcome/_impl.py", line 213, in unwrap
    raise captured_error
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/trio/_core/_run.py", line 1746, in guest_tick
    timeout = self.unrolled_run_next_send.send(self.unrolled_run_gen)
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/outcome/_impl.py", line 185, in send
    return gen.send(self.value)
           ~~~~~~~~^^^^^^^^^^^^
  File "/Users/dev/spire/.venv/lib/python3.14/site-packages/trio/_core/_run.py", line 2945, 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!

Unfortunately, I'm not able to reproduce the error reliably, nor am I certain about where to go looking for the issue. Any insight would be most appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions