Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mkdocs_exporter/formats/pdf/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ def __init__(self, options: dict = {}):
self.context = None
self._launched = False
self.playwright = None
self.lock = asyncio.Lock()
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
self.debug = options.get('debug', False)
self.headless = options.get('headless', True)
self.timeout = options.get('timeout', 60_000)
Expand Down
10 changes: 9 additions & 1 deletion mkdocs_exporter/formats/pdf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,16 @@ async def render(page: Page) -> None:

for page in self.pages:
self.aggregator.append(page.formats['pdf']['path'] + '.aggregate')
os.unlink(page.formats['pdf']['path'] + '.aggregate')

self.aggregator.save()

for page in self.pages:
try:
os.unlink(page.formats['pdf']['path'] + '.aggregate')
except FileNotFoundError:
pass



@event_priority(-100)
def _on_post_build_3(self, **kwargs) -> None:
Expand Down Expand Up @@ -225,6 +231,8 @@ def flatten(items):

for index, page in enumerate(self.pages):
page.index = index
if not hasattr(page, 'formats'):
page.formats = {}


def _enabled(self, page: Page = None) -> bool:
Expand Down