From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RxLE8-0000ey-4z for garchives@archives.gentoo.org; Tue, 14 Feb 2012 16:27:36 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A68B4E09BD; Tue, 14 Feb 2012 16:27:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 72C0EE09BD for ; Tue, 14 Feb 2012 16:27:28 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D9B591B4017 for ; Tue, 14 Feb 2012 16:27:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 9E202E5400 for ; Tue, 14 Feb 2012 16:27:26 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1329236821.608c76a4eb76b88221ba24ca1765765bef827fe1.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_eventloop/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/_eventloop/EventLoop.py X-VCS-Directories: pym/portage/util/_eventloop/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 608c76a4eb76b88221ba24ca1765765bef827fe1 X-VCS-Branch: master Date: Tue, 14 Feb 2012 16:27:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: c83b3e9d-9a54-48ce-bb6e-a9c98aa3aaf2 X-Archives-Hash: 5cc524ff6e86edb0670d8757ce68524b commit: 608c76a4eb76b88221ba24ca1765765bef827fe1 Author: Zac Medico gentoo org> AuthorDate: Tue Feb 14 16:27:01 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Feb 14 16:27:01 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D608c76a4 EventLoop: allow IO event handler re-entrance IO event handlers may be re-entrant, in case something like AbstractPollTask._wait_loop(), needs to be called inside a handler for some reason. --- pym/portage/util/_eventloop/EventLoop.py | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/= _eventloop/EventLoop.py index 37839ab..af0c6a5 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -20,7 +20,7 @@ class EventLoop(object): __slots__ =3D ("args", "callback", "calling", "source_id") =20 class _io_handler_class(SlotObject): - __slots__ =3D ("args", "callback", "calling", "fd", "source_id") + __slots__ =3D ("args", "callback", "fd", "source_id") =20 class _timeout_handler_class(SlotObject): __slots__ =3D ("args", "function", "calling", "interval", "source_id", @@ -178,16 +178,11 @@ class EventLoop(object): while event_handlers and self._poll_event_queue: f, event =3D self._next_poll_event() x =3D event_handlers[f] - if x.calling: - # don't call it recursively - continue - events_handled +=3D 1 - x.calling =3D True - try: - if not x.callback(f, event, *x.args): - self.source_remove(x.source_id) - finally: - x.calling =3D False + # NOTE: IO event handlers may be re-entrant, in case something + # like AbstractPollTask._wait_loop(), needs to be called inside + # a handler for some reason. + if not x.callback(f, event, *x.args): + self.source_remove(x.source_id) except StopIteration: events_handled +=3D 1 =20