summaryrefslogtreecommitdiffstats
path: root/pym/portage/locks.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-01-10 19:07:58 +0000
committerZac Medico <zmedico@gentoo.org>2009-01-10 19:07:58 +0000
commit0964d05f4a513c07a3ee84b742ac486c86700056 (patch)
tree514ed0ae768bdb3925c16f100f74a202ee3a138c /pym/portage/locks.py
parente25182005600e3e5d0591c1d3e2ccc232417419f (diff)
downloadportage-0964d05f4a513c07a3ee84b742ac486c86700056.tar.gz
portage-0964d05f4a513c07a3ee84b742ac486c86700056.tar.bz2
portage-0964d05f4a513c07a3ee84b742ac486c86700056.zip
Use ebegin/eend to indicate when waiting for a lock and when it's acquired.
Thanks to Petteri Räty <belegeuse@g.o> for the suggestion. svn path=/main/trunk/; revision=12415
Diffstat (limited to 'pym/portage/locks.py')
-rw-r--r--pym/portage/locks.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index fc8779285..f557d8096 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -11,6 +11,7 @@ import errno, os, stat, time, types
from portage.exception import DirectoryNotFound, FileNotFound, \
InvalidData, TryAgain
from portage.data import portage_gid
+from portage.output import EOutput
from portage.util import writemsg
from portage.localization import _
@@ -92,19 +93,21 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
raise TryAgain(mypath)
global _quiet
- if _quiet:
- pass
- elif waiting_msg is None:
+ out = EOutput()
+ out.quiet = _quiet
+ if waiting_msg is None:
if isinstance(mypath, int):
- writemsg("waiting for lock on fd %i\n" % myfd,
- noiselevel=-1)
+ waiting_msg = "waiting for lock on fd %i" % myfd
else:
- writemsg("waiting for lock on %s\n" % lockfilename,
- noiselevel=-1)
- elif waiting_msg:
- writemsg(waiting_msg + "\n", noiselevel=-1)
+ waiting_msg = "waiting for lock on %s\n" % lockfilename
+ out.ebegin(waiting_msg)
# try for the exclusive lock now.
- fcntl.lockf(myfd,fcntl.LOCK_EX)
+ try:
+ fcntl.lockf(myfd, fcntl.LOCK_EX)
+ except EnvironmentError, e:
+ out.eend(1, str(e))
+ raise
+ out.eend(os.EX_OK)
elif e.errno == errno.ENOLCK:
# We're not allowed to lock on this FS.
os.close(myfd)