locks.py: use flock with PyPy for issue 747
authorZac Medico <zmedico@gentoo.org>
Thu, 1 Dec 2011 17:52:23 +0000 (09:52 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 1 Dec 2011 17:52:43 +0000 (09:52 -0800)
pym/portage/locks.py

index 9ed1d6a6cfb0bfe6e7325ec412f249f1824fc37f..9cfb87e2d76ac5e17edb9227ed65742c82f2173e 100644 (file)
@@ -8,6 +8,7 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
 
 import errno
 import fcntl
+import platform
 import stat
 import sys
 import time
@@ -27,6 +28,10 @@ if sys.hexversion >= 0x3000000:
 HARDLINK_FD = -2
 _default_lock_fn = fcntl.lockf
 
+if platform.python_implementation() == 'PyPy':
+       # workaround for https://bugs.pypy.org/issue747
+       _default_lock_fn = fcntl.flock
+
 # Used by emerge in order to disable the "waiting for lock" message
 # so that it doesn't interfere with the status display.
 _quiet = False