473,401 Members | 2,146 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,401 software developers and data experts.

Yet another threading question...

Good day all,

Ok, I'm starting to get the hang of this Python thing...really pretty
cool actually. Again, thanx to those that have helped me thus far.

I now have another stumbling block to which I would like help.

Ok, here is my enviroment:

Windows 2K
Python 2.2
MinGW and MSys

I'm writing a Python extension to a 3rd party DLL that controls an
external hardware toy.

One of the DLL methods is a callback registration interface. The 3rd
party DLL is threaded as the callback is asynchronous.

I'm able to call my extension function via Python to "register" my
Python function as the callback function via a C function proxy in the
extension.

All is well until the DLL invokes the callback. When the callback
attempts to invoke my "registered" Python function the Python
interpreter bails with an access violation.

I'm thinking it may have something to do with threading and thus am
asking for your insight to this.

I'm thinking I may have to put my proxy C callback function in it's
own thread. If so, then would some kind soul point me in the right
direction as to how to do this with just the MinGW environment since we
do not have nor use MSVC++.

Thank you.

- Jim

Jul 18 '05 #1
1 2070
I've been pondering the exact same issue, but haven't gotten that far in
wrapping the 3rd-party C library I'm working with.

I was thinking of stubbing the callback to a Python function that sets an
event flag, and have a Python thread monitoring that event to handle it.
I'm not sure if that will cure your access violation, but it may. You
should also make sure that your wrapper gets the GIL (Python Global
Intepreter Lock) before making the Python function call to set the event.

Let me know if you try that, or if you get it to work some other way... I'll
be beating my head into the same problem pretty soon and could use the heads
up!

Thanks,
Kevin Cazabon
"Jim West" <Ji******@checklogix.com> wrote in message
news:ma**********************************@python.o rg...
Good day all,

Ok, I'm starting to get the hang of this Python thing...really pretty
cool actually. Again, thanx to those that have helped me thus far.

I now have another stumbling block to which I would like help.

Ok, here is my enviroment:

Windows 2K
Python 2.2
MinGW and MSys

I'm writing a Python extension to a 3rd party DLL that controls an
external hardware toy.

One of the DLL methods is a callback registration interface. The 3rd
party DLL is threaded as the callback is asynchronous.

I'm able to call my extension function via Python to "register" my
Python function as the callback function via a C function proxy in the
extension.

All is well until the DLL invokes the callback. When the callback
attempts to invoke my "registered" Python function the Python
interpreter bails with an access violation.

I'm thinking it may have something to do with threading and thus am
asking for your insight to this.

I'm thinking I may have to put my proxy C callback function in it's
own thread. If so, then would some kind soul point me in the right
direction as to how to do this with just the MinGW environment since we
do not have nor use MSVC++.

Thank you.

- Jim

Jul 18 '05 #2

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
3
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be...
4
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
4
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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...
0
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,...
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...

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.