Threading + embedding = System Dump.
Gordon McMillan
gmcm at hypernet.com
Mon Jun 26 20:11:55 EDT 2000
Arinté wrote:
>Me again. My usual update
>I have a C++ app/ dll. This is a windows dll is loaded by LoadLibrary.
>The dll holds all the python stuff while the app talks to devices.
>Right now if I was to run a script that has a callback, the script can
>be running and in the middle of the script the app can pop up the
>callback's message window. That is fine. But, I want the option of the
>script waiting for the callback to be called before continuing. So, I
>(well Gordon did) figured I need and event or the Condition Lock stuff,
>but unfortunately this is causing the app to crash. It seems to be
>crashing in PyFrame_New() in frameobject.c (this is python code) on the
>1st line of the function
> PyFrameObject *back = tstate->frame; <----- tstate is null according
> to
>VC++ 6.0 debugger.
That sounds very much like there is no multithreading.
So why doesn't "diz[0].write(mx)" block? Or does it?
Is the real problem here that you're using one of the PyRun_ calls when you
need to go down a level and use PyImport_ etc. so the C++ has some control
over what's going on?
Or maybe that "diz[0].write(mx)" could become
response = diz[0].getresponse(mx)
if response is "eggs":
print "without SPAM? NO WAY!"
Without more clues, we're just as lost as you.
- Gordon
[rest of the message]
>This code is after I call the the callback from my app with
>PyEval_CallObject. Note: this works without threads/event code, but no
>wait. I consider doing the Event part in my dll, but the script should
>be the one to look at the callback message and determine if that is the
>message it wants to continue the script.
>
>I have this code:
>
>import sys
>import threading
>import PossDevice
>import poss
>devlist = [0,1]
>
>def threadFun():
> LOCK.set()
>
>def testCallback(str): #the app calls back here sets the event so the
>script can continue
> mthread.start()
> poss.alert(str)
>
>diz = [0,1]
>LOCK = threading.Event()
>mthread=threading.Thread(None,threadFun)
>poss.initialize(PossDevice.Enumerate)
>diz[0] = PossDevice.QueryDevices(1,11,35)
>diz[0].setCallback(testCallback)
>diz[0].open()
>mx="\x1b\x47""EVENT\n" <--- this will cause a device to send a message
>to the app
>print diz[0].write(mx)
>LOCK.wait() <---wait on event I sent out above
>poss.alert("Waited")
>diz[0].close()
>
>thanks
>
>
More information about the Python-list
mailing list