-
Notifications
You must be signed in to change notification settings - Fork 904
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
fix: asyncio.create_task race issue in page and brower_context #1864
Conversation
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.
I think we can simplify this PR by mirroring our upstream logic:
This means inside
playwright-python/playwright/_impl/_page.py
Line 260 in 9717d13
self._connection.wrap_api_call( |
we try-catch basically inside the lambda.
This means inside
@mxschmitt There are too many calls to |
@mxschmitt done. please check again. |
the bots seem all unhappy and timing out. |
I'm on vacation these days and will check again later. |
@mxschmitt ready for review, this PR contains:
|
@mxschmitt any thoughts about this? should I split the patch for |
Sorry for being slow on this, the last few weeks were busy on my end and we landed a bunch of related changes in the 1.34 release, so we tried not put another change which might introduce regressions into it. I will get back to you in a few days. Would it be possible to add a test/s for it? |
I was talking with my colleagues about it and it still seems, instead of introducing so much complexity, it would be much nicer to do it as the way I explained in #1864 (review). This would fix the actual problem you reported in the first place. Appreciate the efforts, thanks! |
@mxschmitt sorry for delay, it can't try await ... /except in listener. if we change handler to playwright-python/playwright/_impl/_connection.py Lines 409 to 418 in e6a7a37
probably should add def _emit_sync(self, coro: Coroutine, ignore_errors: bool = True) -> None:
fut = asyncio.ensure_future(coro, loop=self._loop)
def cb(f: asyncio.Task) -> None:
self._running_tasks.remove(f)
if f.cancelled():
return
exc: Optional[BaseException] = f.exception()
if exc and not ignore_errors:
self.emit("error", exc)
self._running_tasks.add(fut)
fut.add_done_callback(cb) Reference:
|
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.
Code LGTM.
Please resolve conflicts for this PR.
This PR looks stale and doesn't link a specific GitHub issue which it fixes. I'll close it for now but don't hesitate to re-create it with a test and linked issue. Thanks for your collaboration! |
we should consider
._channel.send
have race condition issue with page close event in some Page's method.Page._update_interception_patterns
is just a situation i encountered.This problem is triggered when the
Page.unroute
method is called when the page is about to close.