Thread termination
Stefan Schukat
SSchukat at dspace.de
Fri Oct 13 06:51:25 EDT 2006
More information about the Python-list mailing list
Fri Oct 13 06:51:25 EDT 2006
- Previous message (by thread): Thread termination
- Next message (by thread): Thread termination
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Reading from your last posts you are using COM objects. Therefore you
should not "kill" the thread since this
would lead to reference leaks. So there are only two ways left:
1. Program a specific interpreter and not use python.exe which
implements an access to PyThreadState_SetAsyncExc
2. Check in the separate thread at specific times a variable which is
set in the main thread.
Both need the try finally construct in the threadfunction to release COM
objects in the right way.
I.e., (taking the source from Roger):
def ThreadFunction(istream, dest):
pythoncom.CoInitialize() // Initialize COM Runtime for this thread
try:
d=pythoncom.CoGetInterfaceAndReleaseStream(istream,
pythoncom.IID_IDispatch)
my_ie=win32com.client.Dispatch(d)
my_ie.Navigate(dest)
finally:
my_ie = None // Release COM object
pythoncom.CoUninitialize() // Release COM Runtime for this
thread
Stefan
- Previous message (by thread): Thread termination
- Next message (by thread): Thread termination
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list