mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
25 lines
573 B
Python
25 lines
573 B
Python
import asyncio
|
|
from guessit.jsonutils import json
|
|
from aio_pika.abc import AbstractIncomingMessage
|
|
from logging import getLogger
|
|
|
|
from providers.rabbit_base import RabbitBase
|
|
|
|
logger = getLogger(__name__)
|
|
|
|
|
|
class Subscriber(RabbitBase):
|
|
QUEUE = "scanner.rescan"
|
|
|
|
async def listen(self, scan):
|
|
async def on_message(message: AbstractIncomingMessage):
|
|
try:
|
|
await scan()
|
|
await message.ack()
|
|
except Exception as e:
|
|
logger.exception("Unhandled error", exc_info=e)
|
|
await message.reject()
|
|
|
|
await self._queue.consume(on_message)
|
|
await asyncio.Future()
|