Parcourir la source

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

tags/v0.2.0
JustAnotherArchivist il y a 4 ans
Parent
révision
d751844626
1 fichiers modifiés avec 7 ajouts et 6 suppressions
  1. +7
    -6
      qwarc/__init__.py

+ 7
- 6
qwarc/__init__.py Voir le fichier

@@ -246,6 +246,13 @@ class QWARC:
sleepTasks.add(sleepTask)
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)
try:
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.item = item
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:
sleepTask.cancel()


Chargement…
Annuler
Enregistrer