From e8bdfce85fbf792eaf8be47c6ecff01f99c94ee6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 3 Nov 2011 23:32:45 -0400 Subject: Don't hold the GIL for blocking operations. --- libdimension-python/wrapper.pyx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libdimension-python/wrapper.pyx') 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: -- cgit v1.2.3