MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / async_cleanup

Function async_cleanup

main.py:123–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122
123async def async_cleanup() -> None:
124 global crawler
125 if crawler:
126 if getattr(crawler, "cdp_manager", None):
127 try:
128 await crawler.cdp_manager.cleanup(force=True)
129 except Exception as e:
130 error_msg = str(e).lower()
131 if "closed" not in error_msg and "disconnected" not in error_msg:
132 print(f"[Main] Error cleaning up CDP browser: {e}")
133
134 elif getattr(crawler, "browser_context", None):
135 try:
136 await crawler.browser_context.close()
137 except Exception as e:
138 error_msg = str(e).lower()
139 if "closed" not in error_msg and "disconnected" not in error_msg:
140 print(f"[Main] Error closing browser context: {e}")
141
142 if config.SAVE_DATA_OPTION in ("db", "sqlite"):
143 await db.close()
144
145if __name__ == "__main__":
146 from tools.app_runner import run

Callers

nothing calls this directly

Calls 2

cleanupMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected