Allow threads to run while processing.
authorbarbieri <barbieri@gmail.com>
Thu, 13 Dec 2007 22:07:02 +0000 (22:07 +0000)
committerbarbieri <barbieri@gmail.com>
Thu, 13 Dec 2007 22:07:02 +0000 (22:07 +0000)
python-lightmediascanner/include/lightmediascanner/c_lightmediascanner.pxd
python-lightmediascanner/lightmediascanner/lightmediascanner.c_lightmediascanner.pyx

index f14a315..ff758cf 100644 (file)
@@ -1,3 +1,9 @@
+cdef extern from "Python.h":
+    # ceval.h
+    cdef enum:
+        Py_BEGIN_ALLOW_THREADS
+        Py_END_ALLOW_THREADS
+
 cdef extern from "lightmediascanner_plugin.h":
     ctypedef struct lms_plugin_t:
         char *name
index c6ea047..d03866a 100644 (file)
@@ -52,7 +52,10 @@ cdef class LightMediaScanner:
         """
         if self.obj == NULL:
             raise ValueError("LightMediaScanner is shallow.")
-        return lms_process(self.obj, top_path)
+        Py_BEGIN_ALLOW_THREADS
+        r = lms_process(self.obj, top_path)
+        Py_END_ALLOW_THREADS
+        return r
 
     def check(self, char *top_path):
         """Check (and update) files under directory.
@@ -64,7 +67,10 @@ cdef class LightMediaScanner:
         """
         if self.obj == NULL:
             raise ValueError("LightMediaScanner is shallow.")
-        return lms_check(self.obj, top_path)
+        Py_BEGIN_ALLOW_THREADS
+        r = lms_check(self.obj, top_path)
+        Py_END_ALLOW_THREADS
+        return r
 
     def parser_find_and_add(self, char *name):
         """Add a new plugin/parser based on it's name.