Skip to content

python >= 3.12 (ubuntu-latest): non-graceful shutdown #84

@ddkohler

Description

@ddkohler

Currently encountering in #82 . Local testing shows the /testing/abstract_method/test_good.py hangs on the context manager running the daemon as a subprocess. Hangs on exit.

<6> INFO : 2025-10-19T11:58:22-0500 : test : Connection made from ('127.0.0.1', 34360) to test
<6> INFO : 2025-10-19T11:58:22-0500 : yaqd_core : Received signal SIGTERM...
<6> INFO : 2025-10-19T11:58:22-0500 : yaqd_core : Cancelling 4 outstanding tasks

Traceback from interrupting (i.e. manual SIGINT does kill the process):

yaqd-core/yaqd_core/testing/_run_daemon.py", line 41, in wrapper
    with subprocess.Popen([sys.executable, pyfile, "--config", config]) as proc:
  File "/usr/lib/python3.12/subprocess.py", line 1118, in __exit__
    self.wait()
  File "/usr/lib/python3.12/subprocess.py", line 1264, in wait
    return self._wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 2053, in _wait
    (pid, sts) = self._try_wait(0)
                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 2011, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

The daemon is getting stuck on shutdown. Though logging, I find that shutdown gets stuck at asyncio.gather

await asyncio.gather(*tasks, return_exceptions=True)

I believe the hanging task is for asyncio.serve_forever. If I pop this from the list of tasks, gather does complete.

If the test tells the individual daemon to shutdown, i.e.

@testing.run_daemon_from_file(here / "good.py", here / "config.toml")
def test_good():
    c = yaqc.Client(39425)
    c.shutdown()

the subprocess does not hang when the wrapper terminates the daemons.

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