summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-11-03 23:32:45 -0400
committerTavian Barnes <tavianator@gmail.com>2011-11-03 23:32:45 -0400
commite8bdfce85fbf792eaf8be47c6ecff01f99c94ee6 (patch)
tree37d588799686bde43a3d588acaa238b9b551b733
parentd952ec7ae90a85673c07a827e92f3c96a33725c1 (diff)
downloaddimension-e8bdfce85fbf792eaf8be47c6ecff01f99c94ee6.tar.xz
Don't hold the GIL for blocking operations.
-rw-r--r--libdimension-python/wrapper.pxd4
-rw-r--r--libdimension-python/wrapper.pyx8
2 files changed, 8 insertions, 4 deletions
diff --git a/libdimension-python/wrapper.pxd b/libdimension-python/wrapper.pxd
index 7ba17e9..2526022 100644
--- a/libdimension-python/wrapper.pxd
+++ b/libdimension-python/wrapper.pxd
@@ -70,10 +70,10 @@ cdef extern from "../libdimension/dimension.h":
ctypedef struct dmnsn_future
- int dmnsn_future_join(dmnsn_future *future)
+ int dmnsn_future_join(dmnsn_future *future) nogil
void dmnsn_future_cancel(dmnsn_future *future)
double dmnsn_future_progress(dmnsn_future *future)
- void dmnsn_future_wait(dmnsn_future *future, double progress)
+ void dmnsn_future_wait(dmnsn_future *future, double progress) nogil
##########
# Timers #
diff --git a/libdimension-python/wrapper.pyx b/libdimension-python/wrapper.pyx
index 738a63f..1afb0ea 100644
--- a/libdimension-python/wrapper.pyx
+++ b/libdimension-python/wrapper.pyx
@@ -67,8 +67,11 @@ cdef class Future:
def join(self):
self._assert_unfinished()
+ cdef int retcode
try:
- if dmnsn_future_join(self._future) != 0:
+ with nogil:
+ retcode = dmnsn_future_join(self._future)
+ if retcode != 0:
raise RuntimeError("background task failed.")
if self._finalizer is not None:
self._finalizer()
@@ -85,7 +88,8 @@ cdef class Future:
def wait(self, progress):
self._assert_unfinished()
- dmnsn_future_wait(self._future, progress)
+ with nogil:
+ dmnsn_future_wait(self._future, progress)
def _assert_unfinished(self):
if self._future == NULL: