13
13
# limitations under the License.
14
14
15
15
import pathlib
16
- from typing import TYPE_CHECKING , Optional , Union , cast
16
+ from typing import Dict , Optional , Union , cast
17
17
18
18
from playwright ._impl ._artifact import Artifact
19
- from playwright ._impl ._connection import from_nullable_channel
19
+ from playwright ._impl ._connection import ChannelOwner , from_nullable_channel
20
20
from playwright ._impl ._helper import locals_to_params
21
+ from playwright ._impl ._local_utils import LocalUtils
21
22
22
- if TYPE_CHECKING : # pragma: no cover
23
- from playwright ._impl ._browser_context import BrowserContext
24
23
25
-
26
- class Tracing :
27
- def __init__ (self , context : "BrowserContext" ) -> None :
28
- self ._context = context
29
- self ._channel = context ._channel
30
- self ._loop = context ._loop
31
- self ._dispatcher_fiber = context ._channel ._connection ._dispatcher_fiber
24
+ class Tracing (ChannelOwner ):
25
+ def __init__ (
26
+ self , parent : ChannelOwner , type : str , guid : str , initializer : Dict
27
+ ) -> None :
28
+ super ().__init__ (parent , type , guid , initializer )
29
+ _local_utils : LocalUtils
32
30
33
31
async def start (
34
32
self ,
@@ -54,7 +52,7 @@ async def stop(self, path: Union[pathlib.Path, str] = None) -> None:
54
52
await self ._channel .send ("tracingStop" )
55
53
56
54
async def _do_stop_chunk (self , file_path : Union [pathlib .Path , str ] = None ) -> None :
57
- is_local = not self ._channel . _connection .is_remote
55
+ is_local = not self ._connection .is_remote
58
56
59
57
mode = "doNotSave"
60
58
if file_path :
@@ -88,4 +86,4 @@ async def _do_stop_chunk(self, file_path: Union[pathlib.Path, str] = None) -> No
88
86
89
87
# Add local sources to the remote trace if necessary.
90
88
if result .get ("sourceEntries" , []):
91
- await self ._context . _local_utils .zip (file_path , result ["sourceEntries" ])
89
+ await self ._local_utils .zip (file_path , result ["sourceEntries" ])
0 commit comments