summaryrefslogtreecommitdiffstats
path: root/libdimension-python/dimension.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension-python/dimension.pyx')
-rw-r--r--libdimension-python/dimension.pyx12
1 files changed, 9 insertions, 3 deletions
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 673dc50..0c0c214 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -60,15 +60,21 @@ cdef class Progress:
finally:
self._progress = NULL
+ def cancel(self):
+ self._assert_unfinished()
+ dmnsn_cancel_progress(self._progress)
+
def progress(self):
- if self._progress == NULL:
- raise RuntimeError("background task finished.")
+ self._assert_unfinished()
return dmnsn_get_progress(self._progress)
def wait(self, progress):
+ self._assert_unfinished()
+ dmnsn_wait_progress(self._progress, progress)
+
+ def _assert_unfinished(self):
if self._progress == NULL:
raise RuntimeError("background task finished.")
- dmnsn_wait_progress(self._progress, progress)
cdef _Progress(dmnsn_progress *progress):
cdef Progress self = Progress.__new__(Progress)