473,414 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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_new(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/mkIQp7AD0RAg5mAJwKD+DTxhmsQu8bzKnzSj5f/p0bjQCgp/Tf
M07tS7uaBFLKi5Z0/IjvSi4=
=doSL
-----END PGP SIGNATURE-----
Jul 18 '05 #1
0 958

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

Similar topics

4
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...
4
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...
5
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...
7
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...
11
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...
3
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. ...
0
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...
0
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...
0
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....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.