Hi Everyone,
I am facing a issue when trying to integrate the python313.dll into my application, when call the websocket in my application, the thread create in python script is not working properly. So I did a sample as below.
Here is what I did:
In my application, after initilize the python, I call PyImport_ImportModule to import my script, and after that, I uses pybind11::object(module.attr(“Initialize”)()).cast(); to call a function in the imported script. My script is something like below.
So the problem is that when I call the initialize function, the new thread will only work at the very beginning, but after exit the initilize funciton, the thread not working any more. I only see one result printed “count down 10” in my log.
Any one faced the issue before? Could you please kindly advise what did I missed out in this scenario?
from threading import Thread
def countdown(n):
while n > 0:
log(0, "count down " + str(n))
n -= 1
time.sleep(5)
def Initialize():
t = Thread(target=countdown, args=(10,))
t.start()
return True