54 lines
2.0 KiB
Diff
54 lines
2.0 KiB
Diff
|
|
From a57465c94ba3a401531853b42e1bd071bcd2e93c Mon Sep 17 00:00:00 2001
|
||
|
|
From: Tamas Nepusz <ntamas@gmail.com>
|
||
|
|
Date: Mon, 2 Nov 2020 15:48:51 +0100
|
||
|
|
Subject: [PATCH] fix: use trio.lowlevel instead of trio.hazmat with Trio >=
|
||
|
|
0.15
|
||
|
|
|
||
|
|
---
|
||
|
|
urwid/_async_kw_event_loop.py | 18 +++++++++++++++---
|
||
|
|
1 file changed, 15 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/urwid/_async_kw_event_loop.py b/urwid/_async_kw_event_loop.py
|
||
|
|
index d146a49..4038405 100644
|
||
|
|
--- a/urwid/_async_kw_event_loop.py
|
||
|
|
+++ b/urwid/_async_kw_event_loop.py
|
||
|
|
@@ -42,7 +42,11 @@ class TrioEventLoop(EventLoop):
|
||
|
|
self._nursery = None
|
||
|
|
|
||
|
|
self._sleep = trio.sleep
|
||
|
|
- self._wait_readable = trio.hazmat.wait_readable
|
||
|
|
+ try:
|
||
|
|
+ self._wait_readable = trio.lowlevel.wait_readable
|
||
|
|
+ except AttributeError:
|
||
|
|
+ # Trio 0.14 or older
|
||
|
|
+ self._wait_readable = trio.hazmat.wait_readable
|
||
|
|
|
||
|
|
def alarm(self, seconds, callback):
|
||
|
|
"""Calls `callback()` a given time from now. No parameters are passed
|
||
|
|
@@ -155,12 +159,20 @@ class TrioEventLoop(EventLoop):
|
||
|
|
|
||
|
|
emulate_idle_callbacks = TrioIdleCallbackInstrument()
|
||
|
|
|
||
|
|
+ try:
|
||
|
|
+ add_instrument = self._trio.lowlevel.add_instrument
|
||
|
|
+ remove_instrument = self._trio.lowlevel.remove_instrument
|
||
|
|
+ except AttributeError:
|
||
|
|
+ # Trio 0.14 or older
|
||
|
|
+ add_instrument = self._trio.hazmat.add_instrument
|
||
|
|
+ remove_instrument = self._trio.hazmat.remove_instrument
|
||
|
|
+
|
||
|
|
with self._trio.MultiError.catch(self._handle_main_loop_exception):
|
||
|
|
- self._trio.hazmat.add_instrument(emulate_idle_callbacks)
|
||
|
|
+ add_instrument(emulate_idle_callbacks)
|
||
|
|
try:
|
||
|
|
await self._main_task()
|
||
|
|
finally:
|
||
|
|
- self._trio.hazmat.remove_instrument(emulate_idle_callbacks)
|
||
|
|
+ remove_instrument(emulate_idle_callbacks)
|
||
|
|
|
||
|
|
def watch_file(self, fd, callback):
|
||
|
|
"""Calls `callback()` when the given file descriptor has some data
|
||
|
|
--
|
||
|
|
2.39.0.windows.2
|
||
|
|
|