Explorar el Código

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

tags/v0.2.0
JustAnotherArchivist hace 4 años
padre
commit
d751844626
Se han modificado 1 ficheros con 7 adiciones y 6 borrados
  1. +7
    -6
      qwarc/__init__.py

+ 7
- 6
qwarc/__init__.py Ver fichero

@@ -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()


Cargando…
Cancelar
Guardar