I have the following Code in a class:
def persistDBThread(self):
while True:
Thread(target=self.__persistDB)
time.sleep(10)
def __persistDB(self):
with open(self.authDBPath, 'w') as outfile:
json.dump(self.authDB, outfile)
The thread gets started in the __ main__ but as soon as I start this thread it is actually blocking in the main execution.
Why is this? I know about the GIL - it's all in the same process. Task switching happens in the same process in micro-thread, but why doesn't it switch back?
Thanks!
Sorry for even asking:
def persistDBThread(self):
Thread(target=self.__persistDB).start()
def __persistDB(self):
while True:
time.sleep(10)
outfile = open(self.authDBPath, 'w')
json.dump(self.authDB, outfile)