Skip to content

Commit

Permalink
Merge pull request #65 from Icexbb/master
Browse files Browse the repository at this point in the history
Fix Windows Shutdown Blocking issue
  • Loading branch information
kexue-z authored Mar 14, 2024
2 parents 1b7bf8f + 908b46a commit baee817
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions nonebot_plugin_htmlrender/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from playwright.async_api import Browser, Error, Page, Playwright, async_playwright

from .config import Config
import asyncio

config = get_plugin_config(Config)

Expand Down Expand Up @@ -74,10 +75,11 @@ async def shutdown_browser():
global _browser
global _playwright
if _browser:
await _browser.close()
if _browser.is_connected():
await _browser.close()
_browser = None
if _playwright:
await _playwright.stop() # type: ignore
# await _playwright.stop()
_playwright = None


Expand All @@ -92,9 +94,9 @@ async def install_browser():
os.environ["PLAYWRIGHT_DOWNLOAD_HOST"] = host
else:
logger.info("使用镜像源进行下载")
os.environ[
"PLAYWRIGHT_DOWNLOAD_HOST"
] = "https://npmmirror.com/mirrors/playwright/"
os.environ["PLAYWRIGHT_DOWNLOAD_HOST"] = (
"https://npmmirror.com/mirrors/playwright/"
)
success = False

if config.htmlrender_browser == "firefox":
Expand Down

0 comments on commit baee817

Please sign in to comment.