Close browser after every selenium use
This commit is contained in:
parent
66c08522f7
commit
e91116fe1b
1 changed files with 3 additions and 0 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue