Threading + embedding = System Dump.

Arinté shouldbe at message.com
Mon Jun 26 13:00:09 EDT 2000


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.
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