Skip to content

Commit

Permalink
fix subprocess remaining
Browse files Browse the repository at this point in the history
submarcos committed Nov 22, 2023
1 parent f5db19e commit 4b9cc76
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/screenshotter/puppeteer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import signal
import subprocess
from tempfile import NamedTemporaryFile

@@ -51,9 +52,10 @@ def take_screenshot(url, width=1920, height=1080, waitfor='body', wait_selectors
screamshotter_css_class,
'--headers',
json.dumps(forward_headers),
], stderr=subprocess.PIPE, env=os.environ)
], stderr=subprocess.PIPE, env=os.environ, preexec_fn=os.setsid)

if command.stderr:
raise ScreenshotterException(command.stderr.decode())

os.killpg(os.getpgid(command.pid), signal.SIGTERM)
return screenshot_file.read()

0 comments on commit 4b9cc76

Please sign in to comment.