Hi friends,
Something in this check-in has a huge impact on all of the
stackless tests in pypy/lib/app-tests.
I think that this was unforeseen by Armin, although it was not
appropriate to blame me for this without any reflection.
I felt exposed to something which I was unable to react on.
Especially since I did not write these modules but Stephan.
Thanks to cfbolz who reminded me how to track such things down.
I would like to know if the resulting errors come from a mis-use
on our side, or if we did all-right so far.
cheers -- chris
[EMAIL PROTECTED] wrote:
> Author: arigo
> Date: Sat Sep 15 15:38:24 2007
> New Revision: 46638
>
> Modified:
> pypy/dist/pypy/tool/cache.py
> Log:
> Protect cache building in a multithreaded py.py.
>
>
> Modified: pypy/dist/pypy/tool/cache.py
> ==============================================================================
> --- pypy/dist/pypy/tool/cache.py (original)
> +++ pypy/dist/pypy/tool/cache.py Sat Sep 15 15:38:24 2007
> @@ -25,6 +25,9 @@
> # Be sure to call the parent __init__() if you override it.
> #
>
> +from threading import RLock
> +lock = RLock() # multithreading protection
> +
>
> class Cache(object):
> def __init__(self):
> @@ -32,20 +35,24 @@
> self._building = {}
>
> def getorbuild(self, key):
> + lock.acquire()
> try:
> - return self.content[key]
> - except KeyError:
> - if key in self._building:
> - raise Exception, "%s recursive building of %r" % (
> - self, key)
> - self._building[key] = True
> try:
> - result = self._build(key)
> - self.content[key] = result
> - finally:
> - del self._building[key]
> - self._ready(result)
> - return result
> + return self.content[key]
> + except KeyError:
> + if key in self._building:
> + raise Exception, "%s recursive building of %r" % (
> + self, key)
> + self._building[key] = True
> + try:
> + result = self._build(key)
> + self.content[key] = result
> + finally:
> + del self._building[key]
> + self._ready(result)
> + return result
> + finally:
> + lock.release()
> getorbuild._annspecialcase_ = "specialize:memo"
>
> def _ready(self, result):
> _______________________________________________
> pypy-svn mailing list
> [EMAIL PROTECTED]
> http://codespeak.net/mailman/listinfo/pypy-svn
--
Christian Tismer :^) <mailto:[EMAIL PROTECTED]>
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev