File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
agentrun/integration/builtin Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -741,17 +741,24 @@ def _get_playwright(self, sb: BrowserSandbox) -> "BrowserPlaywrightSync":
741741 Automatically recreates the connection when the thread that created it has exited,
742742 because Playwright's internal greenlet is bound to the thread that created it.
743743 """
744- if (
745- self ._playwright_sync is not None
746- and self ._playwright_thread is not None
747- and not self ._playwright_thread .is_alive ()
748- ):
749- logger .debug (
750- "Playwright creating thread (id=%s) has exited, recreating"
751- " connection" ,
752- self ._playwright_thread .ident ,
753- )
754- self ._reset_playwright ()
744+ if self ._playwright_sync is not None and self ._playwright_thread is not None :
745+ current_thread = threading .current_thread ()
746+ creator_thread = self ._playwright_thread
747+ if not creator_thread .is_alive () or current_thread is not creator_thread :
748+ if not creator_thread .is_alive ():
749+ logger .debug (
750+ "Playwright creating thread (id=%s) has exited, recreating"
751+ " connection" ,
752+ creator_thread .ident ,
753+ )
754+ else :
755+ logger .debug (
756+ "Playwright creating thread (id=%s) differs from current"
757+ " thread (id=%s), recreating connection" ,
758+ creator_thread .ident ,
759+ current_thread .ident ,
760+ )
761+ self ._reset_playwright ()
755762
756763 if self ._playwright_sync is None :
757764 with self .lock :
You can’t perform that action at this time.
0 commit comments