commit: 13621b62e32a7c21aa08247b33f1faa0a146d0d4 Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Sun Apr 8 21:15:39 2018 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Sun Apr 8 21:15:39 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=13621b62
EventLoop: add get/set_debug methods for asyncio compat (bug 591760) Bug: https://bugs.gentoo.org/591760 pym/portage/util/_eventloop/EventLoop.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py index 1574a6837..4ec67241f 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -102,6 +102,7 @@ class EventLoop(object): @type main: bool """ self._use_signal = main and fcntl is not None + self._debug = bool(os.environ.get('PYTHONASYNCIODEBUG')) self._thread_rlock = threading.RLock() self._thread_condition = threading.Condition(self._thread_rlock) self._poll_event_queue = [] @@ -763,6 +764,19 @@ class EventLoop(object): close() self._poll_obj = None + def get_debug(self): + """ + Get the debug mode (bool) of the event loop. + + The default value is True if the environment variable + PYTHONASYNCIODEBUG is set to a non-empty string, False otherwise. + """ + return self._debug + + def set_debug(self, enabled): + """Set the debug mode of the event loop.""" + self._debug = enabled + _can_poll_device = None
