db fix
This commit is contained in:
parent
ba5e00b24b
commit
17d467b62d
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user