Answer the question
In order to leave comments, you need to log in
Multithreading not working?
Question: I use threading for multithreading, but then a problem arose that the multithreading should solve, but it did not disappear. The question is that the code does not continue to be executed, although multithreading is used.
Here is the code itself:
def egz_checkden():
svv = sqlite.GetInfo()
svv.get_okdata()
itt = sqlite.itt
d = datetime.now()
date = d.strftime('%d.%m.%Y')
print(221)
for x in itt:
if x[4] < date:
svv.useer_id = x[1]
svv.udal_subs()
with open(os.path.abspath(os.getcwd()) + '\HistorySubs\\' + x[1] + '.txt', 'a+') as file:
if x[5] == '0':
file.write(f'User ID: {x[1]}\nUsername: {x[2]}\nData Start: {x[3]}\nData End: {x[4]}\nProdlen: No\nLimit: {x[7]}\n\n')
file.close()
else:
file.write(f'User ID: {x[1]}\nUsername: {x[2]}\nData Start: {x[3]}\nData End: {x[4]}\nProdlen: Yes\nKolvo Prodlen: {x[6]}\nLimit: {x[7]}\n\n')
file.close()
time.sleep(86400)
egz_checkden()
Thread(target=egz_checkden(), args=())
chckden.start()
print('OK!') # Тут код уже не работает
Answer the question
In order to leave comments, you need to log in
Thread(target=egz_checkden () , args=())
When pogromists already learn to distinguish between the result of a function call (with brackets) and a function reference (without brackets).
You now have Python trying to egz_checkden() to get its return value and use it as the target.
And yes, you have an infinite recursion in egz_checkden(), albeit a slow one. Will crash on stack overflow, although not immediately. Don't do that, use a normal loop.
It seems to me that everything should work ... um ... as it should. Why did you decide that it should reach print?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question