diff options
Diffstat (limited to 'urwid/main_loop.py')
-rwxr-xr-x | urwid/main_loop.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/urwid/main_loop.py b/urwid/main_loop.py index 10ea5e1..5149505 100755 --- a/urwid/main_loop.py +++ b/urwid/main_loop.py @@ -28,6 +28,7 @@ import heapq import select import os import signal +import sys from functools import wraps from itertools import count from weakref import WeakKeyDictionary @@ -504,9 +505,10 @@ class MainLoop(object): continue if is_mouse_event(k): event, button, col, row = k - if self._topmost_widget.mouse_event(self.screen_size, - event, button, col, row, focus=True ): - k = None + if hasattr(self._topmost_widget, "mouse_event"): + if self._topmost_widget.mouse_event(self.screen_size, + event, button, col, row, focus=True): + k = None elif self._topmost_widget.selectable(): k = self._topmost_widget.keypress(self.screen_size, k) if k: @@ -888,9 +890,12 @@ class GLibEventLoop(EventLoop): signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2, - signal.SIGWINCH ] + # GLib supports SIGWINCH as of version 2.54. + if not self.GLib.check_version(2, 54, 0): + glib_signals.append(signal.SIGWINCH) + if signum not in glib_signals: # The GLib event loop supports only the signals listed above return @@ -1086,6 +1091,7 @@ class TornadoEventLoop(EventLoop): return # we already patched this instance cls._ioloop_registry[ioloop] = idle_map = {} + # TODO: Add support for Tornado>=5.0.0 ioloop._impl = cls.PollProxy(ioloop._impl, idle_map) def __init__(self, ioloop=None): @@ -1377,7 +1383,7 @@ class AsyncioEventLoop(EventLoop): """ _we_started_event_loop = False - _idle_emulation_delay = 1.0/256 # a short time (in seconds) + _idle_emulation_delay = 1.0/30 # a short time (in seconds) def __init__(self, **kwargs): if 'loop' in kwargs: @@ -1404,7 +1410,12 @@ class AsyncioEventLoop(EventLoop): Returns True if the alarm exists, False otherwise """ - existed = not handle._cancelled + cancelled = ( + handle.cancelled() + if getattr(handle, 'cancelled', None) + else handle._cancelled + ) + existed = not cancelled handle.cancel() return existed @@ -1466,8 +1477,7 @@ class AsyncioEventLoop(EventLoop): loop.stop() if not isinstance(exc, ExitMainLoop): # Store the exc_info so we can re-raise after the loop stops - import sys - self._exc_info = sys.exc_info() + self._exc_info = (type(exc), exc, exc.__traceback__) else: loop.default_exception_handler(context) @@ -1484,6 +1494,12 @@ class AsyncioEventLoop(EventLoop): reraise(*exc_info) +# Import Trio's event loop only if we are on Python 3.5 or above (async def is +# not supported in earlier versions). +if sys.version_info >= (3, 5): + from ._async_kw_event_loop import TrioEventLoop + + def _refl(name, rval=None, exit=False): """ This function is used to test the main loop classes. |