For bug #138840, show a more informative message when waiting for a distfiles lock...
authorZac Medico <zmedico@gentoo.org>
Sat, 3 Mar 2007 09:49:30 +0000 (09:49 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 3 Mar 2007 09:49:30 +0000 (09:49 -0000)
svn path=/main/trunk/; revision=6143

pym/portage/__init__.py
pym/portage/locks.py

index f5e00b06007be87a2f924197d9b9e7fefe24450d..77b730715e93a8edec3c2ec1ca2f05831d43ed60 100644 (file)
@@ -2360,10 +2360,19 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                        writemsg_stdout("\n", noiselevel=-1)
                else:
                        if use_locks and can_fetch:
+                               waiting_msg = None
+                               if "parallel-fetch" in features:
+                                       waiting_msg = ("Downloading '%s'... " + \
+                                               "see /var/log/emerge-fetch.log for details.") % myfile
                                if locks_in_subdir:
-                                       file_lock = portage.locks.lockfile(mysettings["DISTDIR"]+"/"+locks_in_subdir+"/"+myfile,wantnewlockfile=1)
+                                       file_lock = portage.locks.lockfile(
+                                               os.path.join(mysettings["DISTDIR"],
+                                               locks_in_subdir, myfile), wantnewlockfile=1,
+                                               waiting_msg=waiting_msg)
                                else:
-                                       file_lock = portage.locks.lockfile(mysettings["DISTDIR"]+"/"+myfile,wantnewlockfile=1)
+                                       file_lock = portage.locks.lockfile(
+                                               myfile_path, wantnewlockfile=1,
+                                               waiting_msg=waiting_msg)
                try:
                        if not listonly:
                                if fsmirrors and not os.path.exists(myfile_path):
index 3def88a382f376bab55ae9c7d4a44c0f2d8ac8c4..cbf7ee4b5226fb0a375088b1bd36e9150aa7736c 100644 (file)
@@ -17,7 +17,7 @@ def lockdir(mydir):
 def unlockdir(mylock):
        return unlockfile(mylock)
 
-def lockfile(mypath,wantnewlockfile=0,unlinkfile=0):
+def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, waiting_msg=None):
        """Creates all dirs upto, the given dir. Creates a lockfile
        for the given directory as the file: directoryname+'.portage_lockfile'."""
        import fcntl
@@ -76,10 +76,13 @@ def lockfile(mypath,wantnewlockfile=0,unlinkfile=0):
                        raise
                if e.errno == errno.EAGAIN:
                        # resource temp unavailable; eg, someone beat us to the lock.
-                       if type(mypath) == types.IntType:
-                               print "waiting for lock on fd %i" % myfd
-                       else:
-                               print "waiting for lock on %s" % lockfilename
+                       if waiting_msg is None:
+                               if isinstance(mypath, int):
+                                       print "waiting for lock on fd %i" % myfd
+                               else:
+                                       print "waiting for lock on %s" % lockfilename
+                       elif waiting_msg:
+                               print waiting_msg
                        # try for the exclusive lock now.
                        fcntl.lockf(myfd,fcntl.LOCK_EX)
                elif e.errno == errno.ENOLCK: