473,657 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python/C API bug (multithreading )

Hi,

I think I've found a bug in Python/C API and multithreading.

I'm currently creating an intrusion detection system based on mobile agents.

I have an AgentPlatform (C/C++) and 2 agents on it (2 Python scripts:
Snort and Anomaly)

These 2 agents are each running its own Python interpreter (both by
Py_Run*** stuff). Of course I do have Threading on (I mean there is:
PyGILStateEnsur e stuff as well).

I also have an interface that is used by both agents (Python scripts) to
access my Agent Platform (C/C++ program). That interface have one
method: AgentPlatform.g etPacket() - when I call it in Python -
appropriate method AgentPlatform.g etPacket() is called in C/C++
AgentPlatform. Between these two moments somthing bad happens.
This happens when Snort calls Python's AgentPlatform.g etPacket() and
just before C/C++'s AgentPlatform.g etPacket() is called - another agent
- Anomaly Agent calls its Python's AgentPlatform.g etPacket().

In this particular moment everything hangs:((((((((( ((((
Let me show it on an image:

http://www.mobiltek.pl/~mrbpl/tmp/PythonBug.JPG

Is there any simple way to fix this damned bug??

best regards
--

Krzysztof Włodarczyk
Centrum Technologii Mobilnych Mobiltek S.A.
e-mail: kr************* *****@mobiltek. pl
mobile: 502-525-035
This email is confidential and is intended for receipt solely by the individual or entity to which it is addressed. Any review, use, retention, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.
Thank you.

Jun 19 '07 #1
3 1562
Is there any simple way to fix this damned bug??

Sure: just fixed your damned code!!

Regards,
Marttin
Jun 19 '07 #2
Krzysztof Włodarczyk <kr************ ******@mobiltek .plwrote:
I think I've found a bug in Python/C API and multithreading.
You don't state your python version.

There is an old bug about a similar issue :-

http://mail.python.org/pipermail/pyt...ay/053840.html
http://sourceforge.net/tracker/index...70&atid=105470
Is there any simple way to fix this damned bug??
Locking, locking and more locking ;-)

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 20 '07 #3
Nick Craig-Wood pisze:
Krzysztof WÂłodarczyk <kr************ ******@mobiltek .plwrote:
> I think I've found a bug in Python/C API and multithreading.

You don't state your python version.

There is an old bug about a similar issue :-

http://mail.python.org/pipermail/pyt...ay/053840.html
http://sourceforge.net/tracker/index...70&atid=105470

>>
This is apparantly fixed in 2.4.2 despite the absence of anentry in
the NEWS for that release.
>>
Python 2.4.1 and 2.4.4 - the same problem exists :(
> Is there any simple way to fix this damned bug??

Locking, locking and more locking ;-)

damn true brother, thx

--

Krzysztof WĹ‚odarczyk
Centrum Technologii Mobilnych Mobiltek S.A.
e-mail: kr************* *****@mobiltek. pl
mobile: 502-525-035
This email is confidential and is intended for receipt solely by the individual or entity to which it is addressed. Any review, use, retention, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.
Thank you.

Jun 20 '07 #4

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

Similar topics

16
8493
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
53
4340
by: Michael Tobis | last post by:
Someone asked me to write a brief essay regarding the value-add proposition for Python in the Fortran community. Slightly modified to remove a few climatology-related specifics, here it is. I would welcome comments and corrections, and would be happy to contribute some version of this to the Python website if it is of interest. ===
1
3347
by: abhinav | last post by:
Hi guys.I have to implement a topical crawler as a part of my project.What language should i implement C or Python?Python though has fast development cycle but my concern is speed also.I want to strke a balance between development speed and crawler speed.Since Python is an interpreted language it is rather slow.The crawler which will be working on huge set of pages should be as fast as possible.One possible implementation would be...
1
2341
by: abhinav | last post by:
Hi guys.I have read that one cannot perform true multithreading in python due to global interpreter lock mechanism.Suppose i have to implement a crawler on a say cluster system like clusterknoppix so that i can use parallel virtual machine (PVM)for programming in multiprocessor environment or say open MPI.Can i integrate python with PVM or MPI.Can i embed python into C for programming in multiprocessor environment.Is there any way of...
0
1203
by: Cameron Laird | last post by:
QOTW: "Dictionaries are one of the most useful things in Python. Make sure you know how to take adavantage of them..." - Jeremy Sanders "Python has consistently failed to disappoint me." - Tal Einat "super() only works on new-style classes ..." and "has its own set of gotchas": http://groups.google.com/group/comp.lang.python/msg/f44c8c09e1593dcf
0
3413
luke14free
by: luke14free | last post by:
Hello, I was trying to run a multithreading example with python on my phone that lets me to record and play at the same time.I've found an example somewhere but, as expected it doesnt work,,,could someone please correct it? I think it's full of errors or I've really wrong everything...:D import random import threading import time import audio #this is a mobile phone library! # This takes about n/3 seconds to run (about n/3 clumps of...
0
881
by: joop renes | last post by:
hi, i hope this is the right list for the following question of a c++ hacker,python newbie. i have a library in c++ to which i want to add a python GUI and other python stuff.The library has multithreading components, while python uses a reference counted memory model. Usually mixing reference counting with multithreading is frowned upon, at least in the c++ world. what am i to expect in the python world, if i bring multithreading c++...
0
908
by: Gabriel Genellina | last post by:
En Sun, 04 May 2008 11:56:14 -0300, joop renes <jj.renes@hccnet.nlescribió: Python objects are reference counted, *and* you can have many threads running. This is not a problem in itself; Python has a Global Interpreter Lock (GIL) that ensures that addref/releases are properly handled. Only one thread at a time can execute Python code; but your C++ library can use as many threads as you want - as long as they don't call Python code again...
0
8310
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
8827
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...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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
8605
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
7333
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
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2731
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
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.