when executing a simple python script like the following, windbg executes the first line of code in the threaded function, then hangs and crashes itself
```
import pykd
from threading import Thread
def my_func():
print "hi from thread 1\n"
print "hi from thread 2\n"
t = Thread(target=my_func)
t.daemon = True;
t.start()
print "after thread start"
```
Comments: ** Comment from web user: ussrhero **
```
import pykd
from threading import Thread
def my_func():
print "hi from thread 1\n"
print "hi from thread 2\n"
t = Thread(target=my_func)
t.daemon = True;
t.start()
print "after thread start"
```
Comments: ** Comment from web user: ussrhero **
You should exactly know how work multithreading in python, in windbg and pykd.
Your script sample has two problem:
1. It does not wait for additional thread stopping. It leads to fatal python error after the script stopping. So you need add join method call
2. You may not run any call wich can call dbgeng call due to avoid deadlocks with windbg. print leads to IDebugControl::ControlledOutput and it will be wait for command completion in the windbg thread wich is waiting for stop of the additional thread ( you have added join method remember? )
May be you don't need to run code inside in windbg? You can use pykd in standalone program. It is more easy in your case. Yoy will not have to think about deadlocks with windbg