[PATCH; python-imaging-sane] Py_*_ALLOW_THREADS for sane_get_devices and sane_open calls

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH; python-imaging-sane] Py_*_ALLOW_THREADS for sane_get_devices and sane_open calls

Sandro Mani
Hi, following patch also adds Py_*_ALLOW_THREADS macros around the
sane_get_devices and sane_open calls which can take a long time
especially if network-scanners are accessed.

--- Imaging-1.1.7.orig/Sane/_sane.c    2009-11-01 01:44:12.000000000 +0100
+++ Imaging-1.1.7/Sane/_sane.c    2010-12-28 02:17:38.626022947 +0100
@@ -1162,8 +1162,9 @@
      {
        return NULL;
      }
-
+  Py_BEGIN_ALLOW_THREADS
    st=sane_get_devices(&devlist, local_only);
+  Py_END_ALLOW_THREADS
    if (st) return PySane_Error(st);
    if (!(list = PyList_New(0)))
          return NULL;
@@ -1191,7 +1192,9 @@
      rv = newSaneDevObject();
      if ( rv == NULL )
          return NULL;
+    Py_BEGIN_ALLOW_THREADS
      st = sane_open(name, &(rv->h));
+    Py_END_ALLOW_THREADS
      if (st)
        {
          Py_DECREF(rv);

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH; python-imaging-sane] Py_*_ALLOW_THREADS for sane_get_devices and sane_open calls

Fredrik Lundh
Added to trunk. Thanks! /F

2010/12/28 Sandro Mani <[hidden email]>:

> Hi, following patch also adds Py_*_ALLOW_THREADS macros around the
> sane_get_devices and sane_open calls which can take a long time especially
> if network-scanners are accessed.
>
> --- Imaging-1.1.7.orig/Sane/_sane.c    2009-11-01 01:44:12.000000000 +0100
> +++ Imaging-1.1.7/Sane/_sane.c    2010-12-28 02:17:38.626022947 +0100
> @@ -1162,8 +1162,9 @@
>     {
>       return NULL;
>     }
> -
> +  Py_BEGIN_ALLOW_THREADS
>   st=sane_get_devices(&devlist, local_only);
> +  Py_END_ALLOW_THREADS
>   if (st) return PySane_Error(st);
>   if (!(list = PyList_New(0)))
>         return NULL;
> @@ -1191,7 +1192,9 @@
>     rv = newSaneDevObject();
>     if ( rv == NULL )
>         return NULL;
> +    Py_BEGIN_ALLOW_THREADS
>     st = sane_open(name, &(rv->h));
> +    Py_END_ALLOW_THREADS
>     if (st)
>       {
>         Py_DECREF(rv);
>
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig