db fix
This commit is contained in:
parent
ba5e00b24b
commit
17d467b62d
@ -37,7 +37,7 @@ class ArchiveSynchronizer(Component):
|
|||||||
|
|
||||||
@db.connection_context()
|
@db.connection_context()
|
||||||
def _get(self):
|
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 not self.simulate:
|
||||||
if record.archived is not True:
|
if record.archived is not True:
|
||||||
record.archived = self.remote_archive(record) is True
|
record.archived = self.remote_archive(record) is True
|
||||||
|
|||||||
@ -59,7 +59,13 @@ class Threaded(QObject):
|
|||||||
@db.connection_context()
|
@db.connection_context()
|
||||||
# @db.atomic()
|
# @db.atomic()
|
||||||
def start(self):
|
def start(self):
|
||||||
|
# for data in Data.select():
|
||||||
while True:
|
while True:
|
||||||
|
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 = Data()
|
||||||
data.save()
|
data.save()
|
||||||
print(str(int(QThread.currentThreadId())), data.id, flush=True)
|
print(str(int(QThread.currentThreadId())), data.id, flush=True)
|
||||||
@ -81,7 +87,14 @@ for component_name, thread in threads.items():
|
|||||||
# QThread.msleep(1000)
|
# QThread.msleep(1000)
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
while True:
|
while True:
|
||||||
data = Data()
|
for data in list(Data.select().order_by(Data.id.desc()))[:1] + [Data()]:
|
||||||
data.save()
|
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)
|
print("main", data.id, flush=True)
|
||||||
# QThread.msleep(2000)
|
# QThread.msleep(2000)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user