| 1 | Index: subversion/bindings/swig/include/proxy_apr.swg |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- subversion/bindings/swig/include/proxy_apr.swg (revision 18283) |
|---|
| 4 | +++ subversion/bindings/swig/include/proxy_apr.swg (working copy) |
|---|
| 5 | @@ -60,7 +60,10 @@ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | %pythoncode %{ |
|---|
| 9 | +import threading |
|---|
| 10 | + |
|---|
| 11 | application_pool = None |
|---|
| 12 | +application_pool_lock = threading.Lock() |
|---|
| 13 | class GenericSWIGWrapper: |
|---|
| 14 | def __init__(self, this, pool): |
|---|
| 15 | """Create new Generic SWIG wrapper object""" |
|---|
| 16 | @@ -98,21 +101,26 @@ |
|---|
| 17 | def set_parent_pool(self, parent_pool=None): |
|---|
| 18 | """Create a new memory pool""" |
|---|
| 19 | global application_pool |
|---|
| 20 | + |
|---|
| 21 | + try: |
|---|
| 22 | + application_pool_lock.acquire() |
|---|
| 23 | + |
|---|
| 24 | + self._parent_pool = parent_pool or application_pool |
|---|
| 25 | + self._mark_valid() |
|---|
| 26 | + |
|---|
| 27 | + # Protect important functions from GC |
|---|
| 28 | + self._apr_pool_destroy = _core.apr_pool_destroy |
|---|
| 29 | + self._svn_swig_py_clear_application_pool = \ |
|---|
| 30 | + _core.svn_swig_py_clear_application_pool |
|---|
| 31 | + |
|---|
| 32 | + # If we are an application-level pool, |
|---|
| 33 | + # then set this pool to be the application-level pool |
|---|
| 34 | + if not self._parent_pool: |
|---|
| 35 | + svn_swig_py_set_application_pool(self, self) |
|---|
| 36 | + application_pool = self |
|---|
| 37 | + finally: |
|---|
| 38 | + application_pool_lock.release() |
|---|
| 39 | |
|---|
| 40 | - self._parent_pool = parent_pool or application_pool |
|---|
| 41 | - self._mark_valid() |
|---|
| 42 | - |
|---|
| 43 | - # Protect important functions from GC |
|---|
| 44 | - self._apr_pool_destroy = _core.apr_pool_destroy |
|---|
| 45 | - self._svn_swig_py_clear_application_pool = \ |
|---|
| 46 | - _core.svn_swig_py_clear_application_pool |
|---|
| 47 | - |
|---|
| 48 | - # If we are an application-level pool, |
|---|
| 49 | - # then set this pool to be the application-level pool |
|---|
| 50 | - if not self._parent_pool: |
|---|
| 51 | - svn_swig_py_set_application_pool(self, self) |
|---|
| 52 | - application_pool = self |
|---|
| 53 | - |
|---|
| 54 | def valid(self): |
|---|
| 55 | """Check whether this memory pool and its parents |
|---|
| 56 | are still valid""" |
|---|