Skip to content

test: add test for Command + C does not terminate driver connection #1908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 17, 2023

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented May 9, 2023

Issue what this solves is that by default if a user presses Command + C it will send it to the main.py script (good) but also to the driver (bad) which will instantly close the browsers etc. This is because the driver is getting launched as the same process group, we should launch it as a separate process group imo.

See https://unix.stackexchange.com/a/149756

Since upstream we can do the following:

(async () => {
  const browser = await chromium.launch({ handleSIGINT: false, handleSIGHUP: false, handleSIGTERM: false, headless: false });
  const context = await browser.newContext();
  const page = await context.newPage();

  let exited = false;

  process.on('SIGINT', async () => {
    exited = true;
    console.log('SIGINT signal received, graceful shutdown!');
    await context.close();
    await browser.close();
  });
  console.log(`Process Command + C to exit`);
  while (!exited)
    await page.waitForTimeout(1000);

})();

we should be able to do the same in Python. It should be an implementation detail that we are launching a subprocess internally.

#1843

@mxschmitt mxschmitt force-pushed the driver-separate-process-group branch 3 times, most recently from f04a5cb to bf4420e Compare May 11, 2023 20:41
@mxschmitt mxschmitt marked this pull request as ready for review May 12, 2023 16:05
@mxschmitt mxschmitt changed the title chore: launch driver in separate process group test: add test for Command + C does not terminate driver connection May 15, 2023
@mxschmitt mxschmitt force-pushed the driver-separate-process-group branch from e3108a7 to b4c21c9 Compare May 17, 2023 16:31
@mxschmitt mxschmitt merged commit 790757d into main May 17, 2023
@mxschmitt mxschmitt deleted the driver-separate-process-group branch May 17, 2023 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy