OpenCyphal / OpenCyphal/yakut

SIGINT may occasionally result in the stack trace being printed

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
Python
Stars
65
Forks
14
PR merge metrics
No merged PRs in 30d

Description

"Exception ignored in" reports should be suppressed entirely. Here's an example where a publishing command was interrupted normally, and the Python runtime printed the unwanted stack trace:

$ y pub -T 0.01 22:reg.udral.service.actuator.common.sp.vector6 '!$ "[0,0,0,300,0,0]"'
Exception ignored in: <coroutine object publish at 0x7f65cd3d86d0>
Traceback (most recent call last):
  File "/home/groom/.local/lib/python3.10/site-packages/yakut/cmd/publish/_cmd.py", line 311, in publish
    pycyphal.util.broadcast(finalizers[::-1])()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/util/_broadcast.py", line 46, in delegate
    r: typing.Union[R, Exception] = fn(*args, **kwargs)
  File "/home/groom/.local/lib/python3.10/site-packages/yakut/cmd/publish/_executor.py", line 75, in close
    pycyphal.util.broadcast(p.close for p in self._publications)()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/util/_broadcast.py", line 46, in delegate
    r: typing.Union[R, Exception] = fn(*args, **kwargs)
  File "/home/groom/.local/lib/python3.10/site-packages/yakut/cmd/publish/_executor.py", line 135, in close
    self._publisher.close()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/presentation/_port/_publisher.py", line 142, in close
    impl.remove_proxy()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/presentation/_port/_publisher.py", line 212, in remove_proxy
    self.close()  # RAII auto-close
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/presentation/_port/_publisher.py", line 223, in close
    self._maybe_finalizer([self.transport_session])
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/presentation/_presentation.py", line 394, in finalizer
    ts.close()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/redundant/_session/_output.py", line 316, in close
    s.close()
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/redundant/_session/_output.py", line 86, in close
    self.worker.result()
  File "/home/groom/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/groom/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/groom/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/groom/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/groom/.local/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/groom/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/groom/.local/lib/python3.10/site-packages/yakut/main.py", line 332, in proxy
    for e in loop.run_until_complete(asyncio.gather(*orphans, return_exceptions=True)):
  File "/usr/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/redundant/_session/_output.py", line 331, in _inferior_worker_task
    result = await ses.send(wrk.transfer, wrk.monotonic_deadline)
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/can/_session/_output.py", line 206, in send
    return await self._do_send(can_id, transfer, monotonic_deadline)
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/can/_session/_output.py", line 163, in _do_send
    if await self._send_handler(transaction):
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/can/_can.py", line 329, in _do_send
    num_sent = await self._maybe_media.send(
  File "/home/groom/.local/lib/python3.10/site-packages/pycyphal/transport/can/media/socketcan/_socketcan.py", line 140, in send
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 435, in wait_for
    return fut.result()
  File "/home/groom/.local/lib/python3.10/site-packages/yakut/main.py", line 314, in proxy
    return loop.run_until_complete(f(*args, **kwargs))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
KeyboardInterrupt: 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with yakut/cmd/publish/_cmd.py around publish and yakut/main.py around the proxy and event-loop handling shown in the traceback. Reproduce the publishing command and interrupt it with SIGINT, then trace how the KeyboardInterrupt reaches coroutine finalization. Done means a normal interruption no longer prints the "Exception ignored in" report or stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.