From 4ea10d332bb291aaad99b43629681da43f4a51f2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 3 Sep 2010 22:51:59 -0700 Subject: Make portage.locks avoid importing the portage.output module when in quiet mode. This is one less import triggered by ebuild-ipc.py, which should be as lightweight as possible. --- pym/portage/locks.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pym/portage/locks.py') diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 476143cdc..62380ceea 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -17,7 +17,6 @@ from portage.const import PORTAGE_BIN_PATH from portage.exception import DirectoryNotFound, FileNotFound, \ InvalidData, TryAgain, OperationNotPermitted, PermissionDenied from portage.data import portage_gid -from portage.output import EOutput from portage.util import writemsg from portage.localization import _ @@ -121,21 +120,26 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, raise TryAgain(mypath) global _quiet - out = EOutput() - out.quiet = _quiet + if _quiet: + out = None + else: + out = portage.output.EOutput() if waiting_msg is None: if isinstance(mypath, int): waiting_msg = _("waiting for lock on fd %i") % myfd else: waiting_msg = _("waiting for lock on %s\n") % lockfilename - out.ebegin(waiting_msg) + if out is not None: + out.ebegin(waiting_msg) # try for the exclusive lock now. try: fcntl.lockf(myfd, fcntl.LOCK_EX) except EnvironmentError as e: - out.eend(1, str(e)) + if out is not None: + out.eend(1, str(e)) raise - out.eend(os.EX_OK) + if out is not None: + out.eend(os.EX_OK) elif e.errno == errno.ENOLCK: # We're not allowed to lock on this FS. os.close(myfd) -- cgit v1.2.3-1-g7c22