I am implementing python in a application that loads the following script:
I was using WingIDE when I coded this test and it worked fine, the problem is that when I execute it from my application. All it executes is the print("teste 0"). (the application doesn't stop responding, but the thread doesn't work like it should)
Here is my C code:
Thank you for your time.
Yours,
Code:
import time
from threading import Thread
class MyThread(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
i = 0
while i < 100:
print("teste " + str(i))
i += 1
time.sleep(1)
test = MyThread()
test.start()
Here is my C code:
Code:
FILE *f = fopen("main.py", "r");
if (!f)
return;
Py_Initialize();
PyObject* main_module = PyImport_AddModule("__main__");
PyObject* main_dict = PyModule_GetDict(main_module);
PyRun_File(f, "main.py", Py_file_input, main_dict, main_dict);
Thank you for your time.
Yours,