[pypy-svn] r46676 - pypy/dist/pypy/tool
arigo at codespeak.net
arigo at codespeak.net
Sun Sep 16 13:24:21 CEST 2007
Author: arigo
Date: Sun Sep 16 13:24:21 2007
New Revision: 46676
Modified:
pypy/dist/pypy/tool/cache.py
Log:
Allow this to be imported on top of pypy-c-NOthread too.
Modified: pypy/dist/pypy/tool/cache.py
==============================================================================
--- pypy/dist/pypy/tool/cache.py (original)
+++ pypy/dist/pypy/tool/cache.py Sun Sep 16 13:24:21 2007
@@ -25,8 +25,11 @@
# Be sure to call the parent __init__() if you override it.
#
-from threading import RLock
-lock = RLock() # multithreading protection
+try:
+ from threading import RLock
+ lock = RLock() # multithreading protection
+except ImportError:
+ lock = None
class Cache(object):
@@ -35,7 +38,7 @@
self._building = {}
def getorbuild(self, key):
- lock.acquire()
+ if lock: lock.acquire()
try:
try:
return self.content[key]
@@ -52,7 +55,7 @@
self._ready(result)
return result
finally:
- lock.release()
+ if lock: lock.release()
getorbuild._annspecialcase_ = "specialize:memo"
def _ready(self, result):
More information about the Pypy-commit
mailing list