473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extension module initialization called twice


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_InitThre ads 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_InitThre ads
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_InitThre ads ()
(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_VERS ION);
(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_VERS ION);
(gdb)
Simon.

Mar 27 '08 #1
0 1149

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1831
by: Lee Stewart | last post by:
Another question about writing PHP 5 extensions. What's the difference in PHP_MINIT() / PHP_MSHUTDOWN() and PHP_RINIT() / PHP_RSHUTDOWN()? When would a "per request" init be made? Thanks, Lee LeeStewart @ gmail.com
3
3206
by: Anand | last post by:
I have a unexpected issue with python modules (well i kind of know why, but i am trying to find if there is a way around) Intro: I am allowing an external application to actually run python scripts. The external application i am taking about is a test sequencer with a lots of functionality. So the external application has a lot of gui and all the testing logic is done in python. Things work fine when i run regular code and i have been...
8
2761
by: Torsten Mohr | last post by:
Hi, i write an extension module in C at the moment. This module does some work on some own data types that consist of some values. The functions that can change the data are written in C. The question came up if this is by itself thread safe, if some two or more threads try to change these data types, are the C functions by themselves are "atomic" or can they
4
5806
by: Al Norman | last post by:
We have two separate DLLs that do not interact (directly, at least). One is an MFC extension DLL that was built back in VC++ 6 days (but has been recompiled with VS2005). The other is a DLL that contains .Net functions wrapped in C++ (as described by Paul DiLascia -- see http://msdn.microsoft.com/msdnmag/issues/06/06/CAtWork/default.aspx). Both DLLs specify 'Use MFC in a shared DLL'. Since we have an old VC 6 application (large) that we...
1
1684
by: Yue.Nicholas | last post by:
Hi, I have written a small prototype Python extension for a C-library. I have the methods all sorted out and it is working fine. In the C-library, they are various constants of types like string, integer, float and matrix. I'd like to expose them as READONLY values. Is the use of PyMemberDefs a suitable way to provide such access?
5
2026
by: malkarouri | last post by:
Hi everyone, Is it possible to write a Python extension that uses the Boehm garbage collector? I have a C library written that makes use of boehm-gc for memory management. To use that, I have to call GC_INIT() at the start of the program that uses the library. Now I want to encapsulate the library as a CPython extension. The question is really is that possible? And will there be conflicts between the boehm-gc and Python memory...
5
7967
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4, it can open the file. However, when I run Php5 I (now) get this error message: "Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?" This is new. Last time I messed with this, I merely got:
6
1307
by: pianomaestro | last post by:
I have an extension module that gets initialized multiple times because I am using threads. How can this module access global state (not per-thread state) ? It needs to create a singleton. Simon.
6
2272
by: dudeja.rajat | last post by:
Hi, I found on the net that there is something called module initialization. Unfortunately, there is not much information for this. However, small the information I found module initialization can be of use to me in my project. I'm currently messing with a problem where I'm keeping my global variables ( or symbols) in a module and the other mdoules in the project acess these global variables.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.