mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Stop the task when it somehow runs out of wikis
This commit is contained in:
parent
2d287f6397
commit
f731c8600c
|
@ -72,12 +72,18 @@ class RcQueue:
|
||||||
if not self[group]["query"]: # if there is no wiki left in the queue, get rid of the task
|
if not self[group]["query"]: # if there is no wiki left in the queue, get rid of the task
|
||||||
logger.debug(f"{group} no longer has any wikis queued!")
|
logger.debug(f"{group} no longer has any wikis queued!")
|
||||||
all_wikis[wiki].rc_active = -1
|
all_wikis[wiki].rc_active = -1
|
||||||
|
await self.stop_task_group(group)
|
||||||
|
|
||||||
|
async def stop_task_group(self, group):
|
||||||
self[group]["task"].cancel()
|
self[group]["task"].cancel()
|
||||||
del self.domain_list[group]
|
del self.domain_list[group]
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def retrieve_next_queued(self, group) -> Generator[QueuedWiki, None, None]:
|
async def retrieve_next_queued(self, group) -> Generator[QueuedWiki, None, None]:
|
||||||
"""Retrives next wiki in the queue for given domain"""
|
"""Retrives next wiki in the queue for given domain"""
|
||||||
|
if len(self.domain_list[group]["query"]) == 0:
|
||||||
|
await self.stop_task_group(group)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
yield self.domain_list[group]["query"][0]
|
yield self.domain_list[group]["query"][0]
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
|
Loading…
Reference in a new issue