commit: 0f7c9a73a805af5ec70da587b3c7d7f59dabe5ce Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Tue Apr 17 17:57:04 2018 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Tue Apr 17 17:59:10 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0f7c9a73
EventLoop._run_idle_callbacks: remove recursion check This recursion check does not really work because callbacks are removed from self._idle_callbacks before recursion would occur. Fixes: 9772f8f2a58a (EventLoop._idle_add: use thread-safe deque append) pym/portage/util/_eventloop/EventLoop.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py index c38a4defd..a61a3d74a 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -55,7 +55,7 @@ class EventLoop(object): __slots__ = ("callback", "data", "pid", "source_id") class _idle_callback_class(SlotObject): - __slots__ = ("_args", "_callback", "_calling", "_cancelled") + __slots__ = ("_args", "_callback", "_cancelled") class _io_handler_class(SlotObject): __slots__ = ("args", "callback", "f", "source_id") @@ -545,21 +545,11 @@ class EventLoop(object): if x._cancelled: # it got cancelled while executing another callback continue - if x._calling: - # The caller should use call_soon in order to prevent - # recursion here. Raise an error because recursive - # calls would make the remaining count for this loop - # meaningless. - raise AssertionError('recursive idle callback') - x._calling = True - try: - if x._callback(*x._args): - reschedule.append(x) - else: - x._cancelled = True - state_change += 1 - finally: - x._calling = False + if x._callback(*x._args): + reschedule.append(x) + else: + x._cancelled = True + state_change += 1 finally: # Reschedule those that were not cancelled. self._idle_callbacks.extend(reschedule)