Logging queue size when converting singlefiles to archives.

This commit is contained in:
Roland 2025-08-06 15:01:15 -06:00
parent 57081e327e
commit e8b8eb84a9
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -1,3 +1,4 @@
import multiprocessing
import queue
from http import HTTPStatus
from multiprocessing.sharedctypes import SynchronizedArray
@ -91,18 +92,23 @@ async def singlefile_upload_switch_handler(url=None):
from wrolpi.downloader import download_manager, Download
from . import ArchiveDownloader
q: multiprocessing.Queue = api_app.shared_ctx.archive_singlefiles
trace_enabled = logger.isEnabledFor(TRACE_LEVEL)
if trace_enabled:
logger.trace(f'singlefile_upload_switch_handler called for {url}')
try:
singlefile = api_app.shared_ctx.archive_singlefiles.get_nowait()
singlefile = q.get_nowait()
except queue.Empty:
if trace_enabled:
logger.trace(f'singlefile_upload_switch_handler called on empty queue')
return
q_size = q.qsize()
logger.info(f'singlefile_upload_switch_handler queue size: {q_size}')
archive = await lib.singlefile_to_archive(singlefile)
logger.info(f'Created Archive from upload: {archive}')
logger.info(f'Created Archive from upload ({q_size}): {archive}')
name = archive.file_group.title or archive.file_group.url
Events.send_archive_uploaded(f'Created Archive from upload: {name}', url=archive.location)
url = archive.file_group.url