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

Fredrik Lundh fredrik at pythonware.com
Fri Jan 7 17:01:43 CET 2011


Added to trunk. Thanks! /F

2010/12/28 Sandro Mani <manisandro at gmail.com>:
> 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  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list