embed interpreter and thread

antonmuhin íà rambler.ru antonmuhin at rambler.ru
Wed Dec 4 10:41:42 EST 2002


Hello Francois,

FS> TerminateThread(ThreadHD, -1)
>From MSDN:

Remarks
TerminateThread is used to cause a thread to exit. When this occurs,
the target thread has no chance to execute any user-mode code and its
initial stack is not deallocated. DLLs attached to the thread are not
notified that the thread is terminating.

TerminateThread is a dangerous function that should only be used in
the most extreme cases. You should call TerminateThread only if you
know exactly what the target thread is doing, and you control all of
the code that the target thread could possibly be running at the time
of the termination. For example, TerminateThread can result in the
following problems:  <skipped>

--------------------------------------------------------------------

I personally would use another approach. Unfortunately, I don't know
embedding Python in C topic, but just several hints that might help:

1. Use a kind of flag or event to request thread termination.
Drawbacks: it needs additional in Python script or something like
this. If you are interested, I may mail you some C++ snippets (no
Python :()

2. Take a look at IDLE feature to interrupt current script (on Windows
use tray icon) --- it could be easy to reproduce it in your code.

In anyway, if you find a solution, couldn't you post it?

HTH,
Anton.





More information about the Python-list mailing list