v1.8.1: idempotente start() — guard voorkomt dubbele poll-loop bij maubot double-start
This commit is contained in:
parent
6264e73441
commit
c13ec81379
3 changed files with 182 additions and 1 deletions
|
|
@ -123,6 +123,7 @@ class RSSBot(Plugin):
|
|||
dbm: DBManager
|
||||
exclude_paywalled: bool = False
|
||||
poll_task: asyncio.Future
|
||||
_poll_started: bool = False
|
||||
poll_sema: asyncio.Semaphore | None
|
||||
_run_logger: logging.Logger | None = None
|
||||
_run_handler: logging.FileHandler | None = None
|
||||
|
|
@ -138,6 +139,15 @@ class RSSBot(Plugin):
|
|||
return upgrade_table
|
||||
|
||||
async def start(self) -> None:
|
||||
# Idempotentie-guard: maubot kan internal_start() (her)aanroepen via
|
||||
# boot/client/upload/update-paden; Instance.start() zet zijn eigen
|
||||
# started-flag pas ná plugin.start(). Zonder guard ontstaat bij een
|
||||
# tweede (concurrente) aanroep een tweede poll-loop. Check+set is
|
||||
# synchronous (geen await ertussen) → atoom in de event-loop.
|
||||
if self._poll_started:
|
||||
self.log.warning("start() called twice, ignoring duplicate poll task")
|
||||
return
|
||||
self._poll_started = True
|
||||
await super().start()
|
||||
self.on_external_config_update()
|
||||
self.dbm = DBManager(self.database)
|
||||
|
|
@ -177,6 +187,7 @@ class RSSBot(Plugin):
|
|||
|
||||
async def stop(self) -> None:
|
||||
await super().stop()
|
||||
self._poll_started = False
|
||||
self.poll_task.cancel()
|
||||
if self._run_handler:
|
||||
self._run_handler.close()
|
||||
|
|
|
|||
Loading…
Reference in a new issue