468,471 Members | 1,768 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,471 developers. It's quick & easy.

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 1906
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

65 posts views Thread by Anthony_Barker | last post: by
19 posts views Thread by Jane Austine | last post: by
3 posts views Thread by David Harrison | last post: by
4 posts views Thread by Antal Rutz | last post: by
6 posts views Thread by CK | last post: by
7 posts views Thread by Anthony Nystrom | last post: by
4 posts views Thread by Bob | last post: by
4 posts views Thread by DBC User | last post: by
19 posts views Thread by frankiespark | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.