-
-
Notifications
You must be signed in to change notification settings - Fork 76
Fix browser.stopped property. Add test #220
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
Conversation
stephanlensky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the submission and for the added tests! This looks great, if you wouldn't mind just addressing the one comment about not overriding __bool__ I can get this merged.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Hm, it looks like one of the new tests might be failing on Windows, would you mind taking a look? |
This passes on my machine... |
Strike all that... psutil defines their own exception, |
|
Thanks for looking more. I was actually wondering, do you think we need If not though it's np |
|
I'm not sure, I looked for one that works on Windows as well and couldn't find it. I'll have another look for a few mins, I'll reply back when done. |
OK, I remember my logic at the time now. We can't use the stdlib because, AFAICT, there is no way to query for a process state by ID. |
Description
Code that polls for the browser process to stop without calling
browser.stop()first will never detect if the browser has stopped.One example is when running a full browser with UI and the user closes it manually. If a script checks
browser.stoppedit will always return false.The reason is the
_process.returncodeis not updated automatically. You would need to call_process.poll()or _process.wait().The fix is to replace checking
_process.returncodewith checking_process.poll().I've also added a test that will fail without the fix but pass with the fix.
This exposes the fact that
browser.stop()will fail if the browser connection is lost somehow. To fix that I made the Connection class be truthy about being closed and added atry - exceptblock for the stop function.Added tests for validation
Pre-merge Checklist
./scripts/format.shand./scripts/lint.shscripts. My code is properly formatted and has no linting errors.uv run pytestand ensured all tests pass.[Unreleased]section.