extension module initialization called twice

pianomaestro at gmail.com pianomaestro at gmail.com
Thu Mar 27 22:35:48 CET 2008


I have a cython extension module "mux" where the initialization is
being
called more than once (the initmux c function).
I am wondering if my use of multiple threads causes this. Can't
multiple
threads share the same python module ?

The threads are being created from an external C library.
I just call PyEval_InitThreads on startup, and then acquire the
gil from the c callbacks.

Here is my gdb session:

(gdb) break initmux
Breakpoint 1 (initmux) pending.
(gdb) break PyEval_InitThreads
Breakpoint 2 at 0x80c2906
(gdb) run prod-foo.py
Starting program: /usr/bin/python prod-foo.py
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1210001216 (LWP 11155)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Switching to Thread -1210001216 (LWP 11155)]

Breakpoint 2, 0x080c2906 in PyEval_InitThreads ()
(gdb) c
Continuing.
Breakpoint 3 at 0xb787c919: file mux.c, line 6829.
Pending breakpoint "initmux" resolved

Breakpoint 3, initmux () at mux.c:6829
6829      __pyx_m = Py_InitModule4("mux", __pyx_methods, 0, 0,
PYTHON_API_VERSION);
(gdb) c
Continuing.
[New Thread -1419904112 (LWP 11158)]
[New Thread -1420432496 (LWP 11159)]
[New Thread -1420960880 (LWP 11160)]
[New Thread -1421489264 (LWP 11161)]
[New Thread -1422017648 (LWP 11162)]
[New Thread -1422546032 (LWP 11163)]
[New Thread -1424647280 (LWP 11164)]

Breakpoint 3, initmux () at mux.c:6829
6829      __pyx_m = Py_InitModule4("mux", __pyx_methods, 0, 0,
PYTHON_API_VERSION);
(gdb)


Simon.




More information about the Python-list mailing list