Package: python-cwiid
Version: 0.6.00-4
Severity: important
Tags: patch

Creating an instance of cwiid.Wiimote is a blocking operation that
can take quite some time. Python's threading conventions (as per
paragraph 8.1 in the Python/C API Reference Manual) states that
such operations should be guarded by a pair of
Py_{BEGIN,END}_ALLOW_THREADS macros, to avoid blocking all other
threads in the interpreter, but python-cwiid does not do so.

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable'), (50, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.24-1-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
diff -Nurp cwiid-0.6.00/python/Wiimote.c cwiid-0.6.00-mod/python/Wiimote.c
--- cwiid-0.6.00/python/Wiimote.c       2007-06-19 04:28:49.000000000 +0200
+++ cwiid-0.6.00-mod/python/Wiimote.c   2008-07-13 03:50:55.000000000 +0200
@@ -232,8 +232,12 @@ static int Wiimote_init(Wiimote* self, P
                else {
                        bdaddr = *BDADDR_ANY;
                }
-
-               if (!(wiimote = cwiid_open(&bdaddr, flags))) {
+               
+               Py_BEGIN_ALLOW_THREADS
+               wiimote = cwiid_open(&bdaddr, flags);
+               Py_END_ALLOW_THREADS
+               
+               if (!wiimote) {
                        PyErr_SetString(PyExc_RuntimeError,
                                        "Error opening wiimote connection");
                        return -1;

Reply via email to