Sfoglia il codice sorgente

Fix starting another item before stopping on STOP file or memory limit exceedance

tags/v0.2.0
JustAnotherArchivist 4 anni fa
parent
commit
d751844626
1 ha cambiato i file con 7 aggiunte e 6 eliminazioni
  1. +7
    -6
      qwarc/__init__.py

+ 7
- 6
qwarc/__init__.py Vedi File

@@ -246,6 +246,13 @@ class QWARC:
sleepTasks.add(sleepTask) sleepTasks.add(sleepTask)
continue continue


if os.path.exists('STOP'):
logging.info('Gracefully shutting down due to STOP file')
break
if self._memoryLimit and qwarc.utils.uses_too_much_memory(self._memoryLimit):
logging.info(f'Gracefully shutting down due to memory usage (current = {qwarc.utils.get_rss()} > limit = {self._memoryLimit})')
break

cursor = await self.obtain_exclusive_db_lock(db) cursor = await self.obtain_exclusive_db_lock(db)
try: try:
cursor.execute('SELECT id, type, value, status FROM items WHERE status = ? LIMIT 1', (STATUS_TODO,)) cursor.execute('SELECT id, type, value, status FROM items WHERE status = ? LIMIT 1', (STATUS_TODO,))
@@ -285,12 +292,6 @@ class QWARC:
task.itemValue = itemValue task.itemValue = itemValue
task.item = item task.item = item
tasks.add(task) tasks.add(task)
if os.path.exists('STOP'):
logging.info('Gracefully shutting down due to STOP file')
break
if self._memoryLimit and qwarc.utils.uses_too_much_memory(self._memoryLimit):
logging.info(f'Gracefully shutting down due to memory usage (current = {qwarc.utils.get_rss()} > limit = {self._memoryLimit})')
break


for sleepTask in sleepTasks: for sleepTask in sleepTasks:
sleepTask.cancel() sleepTask.cancel()


Caricamento…
Annulla
Salva