This commit is contained in:
matteo porta 2022-10-12 14:52:34 +02:00
parent ba5e00b24b
commit 17d467b62d
2 changed files with 22 additions and 9 deletions

View File

@ -37,7 +37,7 @@ class ArchiveSynchronizer(Component):
@db.connection_context()
def _get(self):
for record in Archive.select().where((Archive.archived != True) | (Archive.uploaded != True)): # using "is not True" breaks the query.
for record in list(Archive.select().where((Archive.archived != True) | (Archive.uploaded != True))): # using "is not True" breaks the query.. # list() forces the complete execution of the query unlocking the db unlike __enter__()
if not self.simulate:
if record.archived is not True:
record.archived = self.remote_archive(record) is True

View File

@ -59,11 +59,17 @@ class Threaded(QObject):
@db.connection_context()
# @db.atomic()
def start(self):
# for data in Data.select():
while True:
data = Data()
data.save()
print(str(int(QThread.currentThreadId())), data.id, flush=True)
# QThread.msleep(2000)
for data in list(Data.select().order_by(Data.id.desc()))[:1] + [Data()]:
data.save()
print(str(int(QThread.currentThreadId())), data.id, flush=True)
# QThread.msleep(2000)
for i in range(2):
data = Data()
data.save()
print(str(int(QThread.currentThreadId())), data.id, flush=True)
# QThread.msleep(2000)
components = {1: Threaded()}
@ -81,7 +87,14 @@ for component_name, thread in threads.items():
# QThread.msleep(1000)
QApplication.processEvents()
while True:
data = Data()
data.save()
print("main", data.id, flush=True)
# QThread.msleep(2000)
for data in list(Data.select().order_by(Data.id.desc()))[:1] + [Data()]:
data.save()
# print(str(int(QThread.currentThreadId())), data.id, flush=True)
print("main", data.id, flush=True)
# QThread.msleep(2000)
for i in range(2):
data = Data()
data.save()
# print(str(int(QThread.currentThreadId())), data.id, flush=True)
print("main", data.id, flush=True)
# QThread.msleep(2000)