BrowserSteps - Forcefully shutdown playwright to prevent any race-conditions waiting for it to shutdown

favicon-fix
dgtlmoon 2 years ago
parent b4d79839bf
commit 55ea983bda

@ -49,16 +49,20 @@ def cleanup_playwright_session():
import psutil import psutil
# playwright's .stop() seems to hang, so lets kill the processes before calling .stop
# a bit hard, but more reliable :/
current_process = psutil.Process() current_process = psutil.Process()
children = current_process.children(recursive=True) children = current_process.children(recursive=True)
for child in children: for child in children:
print (child) # @todo a bug here is that we could be accidently shutting down the playwright from the content checker
print('Child pid is {}'.format(child.pid)) if "playwright" in child.name() or child.name() == "node":
print(child)
# .stop() hangs sometimes if its called when there are no children to process print('Child pid is {}, killing'.format(child.pid))
# but how do we know this is our child? dunno child.terminate()
if children:
browsersteps_playwright_browser_interface.stop() print ("Shutting down playwright interface .stop()")
browsersteps_playwright_browser_interface.stop()
print ("Shutdown of playwright complete")
browsersteps_live_ui_o = {} browsersteps_live_ui_o = {}
browsersteps_playwright_browser_interface = None browsersteps_playwright_browser_interface = None

Loading…
Cancel
Save