Skip to content

Commit

Permalink
Merge pull request #942 from GFDRR/always-close-browser
Browse files Browse the repository at this point in the history
Always close browser
  • Loading branch information
arnaud-morvan authored Apr 17, 2024
2 parents 3fa143b + 8ad6b85 commit eeb8362
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions thinkhazard/views/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ async def render_page(url):
logger.info("Got: {}".format(url))
return BytesIO(await page.pdf({"format": "A4", "printBackground": True}))

chunks = await asyncio.gather(*[
render_page(url) for url in pages
])

await browser.close()
try:
chunks = await asyncio.gather(*[
render_page(url) for url in pages
])
finally:
await browser.close()

# merge all pages
writer = PdfFileWriter()
Expand Down

0 comments on commit eeb8362

Please sign in to comment.