emergelog: pass path to lockfile, not file object
authorZac Medico <zmedico@gentoo.org>
Wed, 14 Dec 2011 07:31:43 +0000 (23:31 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 14 Dec 2011 07:31:43 +0000 (23:31 -0800)
pym/_emerge/emergelog.py

index d6ef1b4dfe3011ae9780763d4eef7fa7d9cf72f6..b1b093f52989fbe66360ccdf532de84fe7cc1d8f 100644 (file)
@@ -49,15 +49,12 @@ def emergelog(xterm_titles, mystr, short_msg=None):
                        portage.util.apply_secpass_permissions(file_path,
                                uid=portage.portage_uid, gid=portage.portage_gid,
                                mode=0o660)
-               mylock = None
+               mylock = portage.locks.lockfile(file_path)
                try:
-                       mylock = portage.locks.lockfile(mylogfile)
                        mylogfile.write(_log_fmt % (time.time(), mystr))
-                       mylogfile.flush()
-               finally:
-                       if mylock:
-                               portage.locks.unlockfile(mylock)
                        mylogfile.close()
+               finally:
+                       portage.locks.unlockfile(mylock)
        except (IOError,OSError,portage.exception.PortageException) as e:
                if secpass >= 1:
                        print("emergelog():",e, file=sys.stderr)