adrienbrignon / mkdocs-exporter

⚡ The fastest and most configurable plugin for MkDocs, allowing seamless export of individual pages and/or entire documentation as PDF documents.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
81 stars 8 forks source link

RuntimeError when `mkdocs serve` rebuilds #47

Open nbanyan opened 1 week ago

nbanyan commented 1 week ago

Triggering a rebuild gives RuntimeError: There is no current event loop in thread 'MainThread'

It's thrown when formats.pdf.Browser.__init__() attempts to call asyncio.Lock() again.

One solution would be to catch the exception:

try:
  self.lock = asyncio.Lock()
except RuntimeError as e:
  if 'no current event loop' in str(e):
    asyncio.set_event_loop(asyncio.new_event_loop())
    self.lock = asyncio.Lock()
  else:
    raise