473,785 Members | 3,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with threads and embedding

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i wrote a module for ctrlproxy which embedds python and provides an api
that ctrlproxy is scriptable.

Every script is started in an own interpreter instance and registers
some callback functions for different events.
The module is threadsafe and everything works just fine, with one
exceptions, dead threads are not removed from the process list.

import time
import thread
import sys
import os

def runme():
time.sleep(2)
print "PID: %s" %(os.getpid())
print "PID: %s" %(os.getppid())
print " ------------ END -------------"

print thread.start_ne w(runme,())
Results in:
poelzi 20633 0.1 2.2 17296 11508 pts/17 S 02:24 0:12 | \_
gdb ./ctrlproxy
poelzi 15187 0.7 1.0 13136 5464 pts/17 T 05:55 0:00 |
\_ /home/poelzi/Projects/ctrlproxy/ctrlproxy
poelzi 15189 0.0 1.0 13136 5464 pts/17 T 05:55 0:00 |
~ \_ /home/poelzi/Projects/ctrlproxy/ctrlproxy
poelzi 15190 0.0 0.0 0 0 pts/17 Z 05:55 0:00 |
~ \_ [ctrlproxy] <defunct>

I tried to spend time in every created thread through the advanced
debugging api, but this changed nothing. I experimented with the
sys.exitfunc without success.
I added some debugging function to see what happens.

[...]
** INFO: Loading Python scripts
CREATED THREAD 16384
[...]

16384 is the thread of the script

[...]
ID:0:/home/poelzi/Projects/ctrlproxy/example/test.py
Joining channel #test
IS: 0x80cba58 134560928
TS: 0x810e2d0 16386
TS: 0x80fe860 16384
TS: 0x80bb028 16384
IS: 0x8083638 16384
TS: 0x8083660 16384
IS: 0x80cba58 134560928
TS: 0x810e2d0 16386
TS: 0x80fe860 16384
TS: 0x80bb028 16384
IS: 0x8083638 16384
TS: 0x8083660 16384
** INFO: ------------ END -------------
IS: 0x80cba58 134560928
TS: 0x80fe860 16384
TS: 0x80bb028 16384
IS: 0x8083638 16384
TS: 0x8083660 16384
IS: 0x80cba58 134560928
TS: 0x80fe860 16384
TS: 0x80bb028 16384
IS: 0x8083638 16384
TS: 0x8083660 16384

IS is a interpreter state and TS a thread state.
16386 seems to be the thread created by the script. After it exists,
Python knows nothing about the thread anymore, but the return code
didn't seems to be catched.
The sourcecode is to large and CVSweb currently broken...
I uploaded the code @
http://files.poelzi.org/tmp/ctrlproxy_python/

http://files.poelzi.org/tmp/ctrlproxy_python/python.c is the main file.
Any hints for me so solve this anoying problem ? :(
regards
~ Daniel

- --
nihil me cirumdat

... . .. ... . . .. . ... . .. . ... . . .
pgp key @ http://files.poelzi.org/pgp.txt
ED80 E53D 5269 4BB1 1E73 3A53 CBF9 A421 0A7B 003D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Debian - http://enigmail.mozdev.org

iD8DBQE/+sOVy/mkIQp7AD0RAg5mA JwKD+DTxhmsQu8b zKnzSj5f/p0bjQCgp/Tf
M07tS7uaBFLKi5Z 0/IjvSi4=
=doSL
-----END PGP SIGNATURE-----
Jul 18 '05 #1
0 973

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

Similar topics

4
2790
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been working with Python for a year or more now, but only doing simple extending in C/C++. I'm now attempting some embedding and several questions have come to mind. BTW - I'm running Windows 2000 with Python23 and VisualC++ developers
4
1684
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application running on Solaris and need urgent clarification on the embedding architecture and its correct usage (as I am experience weird behaviors). Can anyone clarify:
5
1706
by: Rob Durant | last post by:
Hi, I have a multi-threaded application (have also tried as service - same behaviour) that runs fine on XP, but not on 2003. Symptoms are: Threads are started normally, locks acquired and released as needed, runs fine for some time, then stops - Visual Studio detects no exceptions, and I have placed break points on all the handling code to catch them. No errors / failures are logged, but child threads have all exited, and I am left...
7
1872
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long as 2300 ms to complete. This is fairly rare, but the test code below will definitely show it. Somehow, I must not have my design right. The idea of this code is that I do two different types of processing ( 1-starting and 2-ending) based on...
11
2213
by: Steve Smith | last post by:
I have written a winforms application that launches approximately 150 threads with Thread.ThreadStart() Each thread uses CDO 1.21 to logon to a different Exchange mailbox and send/receive a number of mail messages, reporting back to the UI thread through the use of a Queue object. When all messages that are expected have been received, each thread sends a final update to the UI and the method should exit, which should terminate the...
3
2924
by: John Pye | last post by:
Hi all I have been working on some new code that embeds python in an C application. The embedding is working fine under Linux but crashing under Windows (XP) when I reach the following step. PyRun_AnyFile(f,name); If there's some python exception being thrown by the PyRun_AnyFile call, how can I retrieve it from C?
0
802
by: Sven Rech | last post by:
Hi, I'm the author of an application written in C, which should now be extended with a python plugin system. It already works very good, but I now have a problem: Threading functionality within the python modules, that my C app loads and calls, doesn't work. This means, the threads do not run (the same python code works correct if I just start it with the normal python interpreter).
0
807
by: Sven Rech | last post by:
Hi, I have a written a C program which makes use of python embedding. I want to find out all threads that a loaded module has started. But I can't find anything about this in the docs. Is it possible?
0
2099
by: marcell71 | last post by:
I'm trying to get Boost.Python to working using the instructions here: http://www.boost.org/libs/python/doc/building.html. I am on step 3.1.4 and am getting a linking error that I can't figure out. This is the error: ~/Desktop/boost_1_34_1/libs/python/example/quickstart$ bjam toolset=gcc --verbose-test test Building Boost.Regex with the optional Unicode/ICU support disabled. Please refer to the Boost.Regex documentation for more...
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,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10087
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,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
1
4046
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
2877
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.