mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-16 14:03:44 +08:00
fix(core): prevent duplicate startup logo from nested router lifespan events
FastAPI's merged_lifespan mechanism triggers lifespan events for each nested router layer. Since program_router is included in v1, which is included in app, the startup handler was being called 3 times. Added _startup_done flag to ensure Program.startup() only executes once. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -30,6 +30,10 @@ figlet = r"""
|
||||
|
||||
|
||||
class Program(RenameThread, RSSThread, OffsetScanThread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._startup_done = False
|
||||
|
||||
@staticmethod
|
||||
def __start_info():
|
||||
for line in figlet.splitlines():
|
||||
@@ -41,6 +45,10 @@ class Program(RenameThread, RSSThread, OffsetScanThread):
|
||||
logger.info("Starting AutoBangumi...")
|
||||
|
||||
async def startup(self):
|
||||
# Prevent duplicate startup due to nested router lifespan events
|
||||
if self._startup_done:
|
||||
return
|
||||
self._startup_done = True
|
||||
self.__start_info()
|
||||
if not self.database:
|
||||
first_run()
|
||||
|
||||
Reference in New Issue
Block a user