Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions playwright/_impl/_sync_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
import inspect
import traceback
from types import TracebackType
from typing import Any, Awaitable, Callable, Dict, Generic, List, Type, TypeVar, cast
from typing import (
Any,
Callable,
Coroutine,
Dict,
Generator,
Generic,
List,
Type,
TypeVar,
Union,
cast,
)

import greenlet

Expand Down Expand Up @@ -75,10 +87,13 @@ def __init__(self, impl_obj: Any) -> None:
def __str__(self) -> str:
return self._impl_obj.__str__()

def _sync(self, coro: Awaitable) -> Any:
def _sync(
self,
coro: Union[Coroutine[Any, Any, Any], Generator[Any, Any, Any]],
) -> Any:
__tracebackhide__ = True
g_self = greenlet.getcurrent()
task = self._loop.create_task(coro)
task: asyncio.tasks.Task[Any] = self._loop.create_task(coro)
setattr(task, "__pw_stack__", inspect.stack())
setattr(task, "__pw_stack_trace__", traceback.extract_stack())

Expand Down