Skip to content

Commit 16944a3

Browse files
committed
Merge remote-tracking branch 'origin/pr/208'
* origin/pr/208: Use glib's native asyncio integration when available
2 parents f0124b2 + 845750a commit 16944a3

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

archlinux/PKGBUILD.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ depends=(
1111
bash
1212
glibc
1313
python
14+
python-gobject
1415
python-setuptools
1516
pam
1617
qubes-libvchan

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Build-Depends:
1010
dh-python,
1111
lsb-release,
1212
python3-setuptools,
13-
python3-gbulb,
13+
python3-gi (>= 3.50.0) | python3-gbulb,
1414
pandoc,
1515
Standards-Version: 4.4.0.1
1616
Homepage: https://www.qubes-os.org

qrexec/tools/qrexec_policy_agent.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,22 @@
3131
import importlib.resources
3232

3333
# pylint: disable=import-error,wrong-import-position
34+
# pylint: disable=wrong-import-order
3435
import gi
3536

3637
gi.require_version("Gtk", "3.0")
3738
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, Gio
3839

39-
# pylint: enable=import-error
40+
try:
41+
from gi.events import GLibEventLoopPolicy
4042

41-
# pylint: disable=wrong-import-order
42-
import gbulb
43+
HAS_GBULB = False
44+
except ImportError:
45+
import gbulb
46+
47+
HAS_GBULB = True
48+
49+
# pylint: enable=import-error
4350

4451
from .. import POLICY_AGENT_SOCKET_PATH
4552
from ..utils import sanitize_domain_name, sanitize_service_name
@@ -508,7 +515,18 @@ def _close(self):
508515
self._rpc_window.close()
509516

510517
async def _wait_for_close(self):
511-
await gbulb.wait_signal(self._rpc_window, "delete-event")
518+
future = asyncio.Future()
519+
hnd = None
520+
521+
def _delete_callback(*k):
522+
self._rpc_window.disconnect(hnd)
523+
future.set_result(k)
524+
525+
hnd = self._rpc_window.connect(
526+
"delete-event",
527+
_delete_callback,
528+
)
529+
await future
512530

513531
def _show(self):
514532
self._rpc_window.set_keep_above(True)
@@ -668,10 +686,15 @@ def notify(self, resolution, service, argument, source, target):
668686
def main():
669687
args = parser.parse_args()
670688

671-
gbulb.install()
689+
if HAS_GBULB:
690+
# pylint: disable=used-before-assignment
691+
gbulb.install()
692+
else:
693+
asyncio.set_event_loop_policy(GLibEventLoopPolicy())
694+
loop = asyncio.get_event_loop()
672695
agent = PolicyAgent(args.socket_path)
673696

674-
asyncio.run(agent.run())
697+
loop.run_until_complete(agent.run())
675698

676699

677700
if __name__ == "__main__":

rpm_spec/qubes-qrexec.spec.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ BuildRequires: python%{python3_pkgversion}-rpm-macros
4747
BuildRequires: systemd-rpm-macros
4848

4949
Requires: python%{python3_pkgversion}
50+
%if 0%{?fedora} < 42
5051
Requires: python%{python3_pkgversion}-gbulb
52+
%else
53+
Requires: python%{python3_pkgversion}-gobject >= 3.50.0
54+
%endif
5155
%if 0%{?is_opensuse}
5256
Requires: python%{python3_pkgversion}-pyinotify
5357
%else

0 commit comments

Comments
 (0)