extension module initialization called twice

P

pianomaestro

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top