Close browser after every selenium use

This commit is contained in:
cuom1999 2021-06-07 15:23:16 -05:00
parent 66c08522f7
commit e91116fe1b

View file

@ -300,16 +300,19 @@ class SeleniumPDFRender(BasePdfMaker):
except TimeoutException: except TimeoutException:
logger.error('PDF math rendering timed out') logger.error('PDF math rendering timed out')
self.log = self.get_log(browser) + '\nPDF math rendering timed out' self.log = self.get_log(browser) + '\nPDF math rendering timed out'
browser.quit()
return return
response = browser.execute_cdp_cmd('Page.printToPDF', self.template) response = browser.execute_cdp_cmd('Page.printToPDF', self.template)
self.log = self.get_log(browser) self.log = self.get_log(browser)
if not response: if not response:
browser.quit()
return return
with open(self.pdffile, 'wb') as f: with open(self.pdffile, 'wb') as f:
f.write(base64.b64decode(response['data'])) f.write(base64.b64decode(response['data']))
self.success = True self.success = True
browser.quit()
if HAS_PUPPETEER: if HAS_PUPPETEER: