From: Zac Medico Date: Thu, 3 Jan 2013 22:42:41 +0000 (-0800) Subject: portdbapi: use global_event_loop when safe X-Git-Tag: v2.2.0_alpha150~54 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=400a2a983b374ec54e7b574789d1f94752581b81;p=portage.git portdbapi: use global_event_loop when safe --- diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 35f4e2d09..ebb1be87a 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -34,6 +34,7 @@ from portage import _encodings from portage import _unicode_encode from portage import OrderedDict from portage.util._eventloop.EventLoop import EventLoop +from portage.util._eventloop.global_event_loop import global_event_loop from _emerge.EbuildMetadataPhase import EbuildMetadataPhase import os as _os @@ -96,7 +97,6 @@ class portdbapi(dbapi): # this purpose because doebuild makes many changes to the config # instance that is passed in. self.doebuild_settings = config(clone=self.settings) - self._event_loop = EventLoop(main=False) self.depcachedir = os.path.realpath(self.settings.depcachedir) if os.environ.get("SANDBOX_ON") == "1": @@ -195,6 +195,17 @@ class portdbapi(dbapi): self._aux_cache = {} self._broken_ebuilds = set() + @property + def _event_loop(self): + if portage._internal_warnings: + # For internal portage usage, the global_event_loop is safe. + return global_event_loop() + else: + # For external API consumers, use a local EventLoop, since + # we don't want to assume that it's safe to override the + # global SIGCHLD handler. + return EventLoop(main=False) + def _create_pregen_cache(self, tree): conf = self.repositories.get_repo_for_location(tree) cache = conf.get_pregenerated_cache(