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
For zaza, for various reasons, we need/have to run python-libjuju's async loop in a background thread. This is because the zaza is written as a non-blocking test framework on top of unitest. However, the async thread needs to keep running to get status updates and so to make it all work, python-libjuju runs on the background thread.
However, due to python/cpython#87173 and a recent-ish change this now blows up on py3.8, py3.9 and py3.10. This is a major problem for our CI as it runs py3.8 test runners (a limitation we do eventually need to solve).
The traceback is here:
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/controller.py", line 108, in connect
await self._connector.connect_controller(controller_name, **kwargs)
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connector.py", line 127, in connect_controller
await self.connect(
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connector.py", line 86, in connect
self._connection = await Connection.connect(**kwargs)
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 356, in connect
await self._connect_with_redirect([_ep])
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 908, in _connect_with_redirect
login_result = await self._connect_with_login(endpoints)
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 875, in _connect_with_login
await self._connect(endpoints)
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 824, in _connect
result = await task
File "/usr/lib/python3.10/asyncio/tasks.py", line 571, in _wait_for_one
return f.result() # May raise f.exception().
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 813, in _try_endpoint
return await self._open(endpoint, cacert)
File "/home/runner/work/zaza/zaza/.tox/func-target/lib/python3.10/site-packages/juju/client/connection.py", line 430, in _open
loop.add_signal_handler(sig, _exit_tasks)
File "/usr/lib/python3.10/asyncio/unix_events.py", line 107, in add_signal_handler
raise RuntimeError(str(exc))
RuntimeError: set_wakeup_fd only works in main thread of the main interpreter
func-target: exit 1 (0.70 seconds) /home/runner/work/zaza/zaza> functest-run-suite --keep-model --bundle first pid=11317
.pkg: _exit> python /home/runner/.local/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
func-target: FAIL code 1 (26.05=setup[24.57]+cmd[0.78,0.70] seconds)
evaluation failed :( (26.13 seconds)
Error: Process completed with exit code 1.
The easiest fix is probably to wrap the code in the same way as in juju/jasyncio.py:
added=Falsetry:
loop.add_signal_handler(signal.SIGINT, abort)
added=Trueexcept (ValueError, OSError, RuntimeError) ase:
# add_signal_handler doesn't work in a threadif'main thread'notinstr(e):
raise
1. Because if someone runs pylibjuju in an off-main thread, then
add_signal_handler will (rightfully) complain (see issue juju#1010).
2. Pylibjuju as a library shouldn't enforce a certain way of handling
signals. Clients should install their handlers however they wanna
handle them.
Fixesjuju#1010
#1014
#### Description
In #1010 it's reported that running pylibjuju in an off-main thread blows up the `add_signal_handler` (for a good reason). Also per the discussion in the #1011 about signal handlers, this PR removes the code that installs signal handlers to the event loop at the connection creation. See [my comment](#1011 (comment)) in #1011 for details about reasoning.
Fixes#1010
Description
For zaza, for various reasons, we need/have to run python-libjuju's async loop in a background thread. This is because the zaza is written as a non-blocking test framework on top of unitest. However, the async thread needs to keep running to get status updates and so to make it all work, python-libjuju runs on the background thread.
However, due to python/cpython#87173 and a recent-ish change this now blows up on py3.8, py3.9 and py3.10. This is a major problem for our CI as it runs py3.8 test runners (a limitation we do eventually need to solve).
The traceback is here:
The easiest fix is probably to wrap the code in the same way as in
juju/jasyncio.py
:Urgency
Annoying bug in our test suite
Python-libjuju version
Juju version
3.1
Reproduce / Test
The text was updated successfully, but these errors were encountered: