We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Running playwright raises PermissionError on Linux
### Reproducing the error

- Created a virtual environment 
- Installed playwright with `python -m pip install playwright`

Tried to run some code

```python
from playwright import sync_playwright

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch()
        page = browser.newPage()
        page.goto('http://whatsmyuseragent.org/')
        page.screenshot(path=f'example-{browser_type.name}.png')
        browser.close()
```

Then it raised this error

```python
PermissionError: [Errno 13] Permission denied: '/home/leno/Desktop/open-source/pwright/env/lib/python3.8/site-packages/playwright/drivers/driver-linux
```

I think this is not a normal behavior since running Python under sudo is a terrible idea.

**OS**: Ubuntu 20.04
**Python Version**: 3.8.2
**Playwright Version**:  0.142.3



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `playwright/path_utils.py`
Content:
```
1 import inspect
2 from pathlib import Path
3 
4 
5 def get_file_dirname() -> Path:
6     """Returns the callee (`__file__`) directory name"""
7     frame = inspect.stack()[1]
8     module = inspect.getmodule(frame[0])
9     assert module
10     return Path(module.__file__).parent.absolute()
11
```

Path: `playwright/main.py`
Content:
```
1 # Copyright (c) Microsoft Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import asyncio
16 import io
17 import os
18 import stat
19 import subprocess
20 import sys
21 from pathlib import Path
22 from typing import Any
23 
24 from greenlet import greenlet
25 
26 from playwright.async_api import Playwright as AsyncPlaywright
27 from playwright.connection import Connection
28 from playwright.helper import Error
29 from playwright.object_factory import create_remote_object
30 from playwright.path_utils import get_file_dirname
31 from playwright.playwright import Playwright
32 from playwright.sync_api import Playwright as SyncPlaywright
33 from playwright.sync_base import dispatcher_fiber, set_dispatcher_fiber
34 
35 
36 def compute_driver_executable() -> Path:
37     package_path = get_file_dirname()
38     platform = sys.platform
39     if platform == "darwin":
40         return package_path / "drivers" / "driver-darwin"
41     elif platform == "linux":
42         return package_path / "drivers" / "driver-linux"
43     elif platform == "win32":
44         result = package_path / "drivers" / "driver-win32-amd64.exe"
45         if result.exists():
46             return result
47         return package_path / "drivers" / "driver-win32.exe"
48     return package_path / "drivers" / "driver-linux"
49 
50 
51 async def run_driver_async() -> Connection:
52     driver_executable = compute_driver_executable()
53 
54     # Sourced from: https://github.com/pytest-dev/pytest/blob/49827adcb9256c9c9c06a25729421dcc3c385edc/src/_pytest/faulthandler.py#L73-L80
55     def _get_stderr_fileno() -> int:
56         try:
57             return sys.stderr.fileno()
58         except io.UnsupportedOperation:
59             # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
60             # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
61             # This is potentially dangerous, but the best we can do.
62             return sys.__stderr__.fileno()
63 
64     proc = await asyncio.create_subprocess_exec(
65         str(driver_executable),
66         stdin=asyncio.subprocess.PIPE,
67         stdout=asyncio.subprocess.PIPE,
68         stderr=_get_stderr_fileno(),
69         limit=32768,
70     )
71     assert proc.stdout
72     assert proc.stdin
73     connection = Connection(
74         proc.stdout, proc.stdin, create_remote_object, asyncio.get_event_loop()
75     )
76     return connection
77 
78 
79 def run_driver() -> Connection:
80     loop = asyncio.get_event_loop()
81     if loop.is_running():
82         raise Error("Can only run one Playwright at a time.")
83     return loop.run_until_complete(run_driver_async())
84 
85 
86 class SyncPlaywrightContextManager:
87     def __init__(self) -> None:
88         self._connection = run_driver()
89         self._playwright: SyncPlaywright
90 
91     def __enter__(self) -> SyncPlaywright:
92         g_self = greenlet.getcurrent()
93 
94         def callback_wrapper(playwright_impl: Playwright) -> None:
95             self._playwright = SyncPlaywright(playwright_impl)
96             g_self.switch()
97 
98         self._connection.call_on_object_with_known_name("Playwright", callback_wrapper)
99         set_dispatcher_fiber(greenlet(lambda: self._connection.run_sync()))
100         dispatcher_fiber().switch()
101         playwright = self._playwright
102         playwright.stop = self.__exit__  # type: ignore
103         return playwright
104 
105     def start(self) -> SyncPlaywright:
106         return self.__enter__()
107 
108     def __exit__(self, *args: Any) -> None:
109         self._connection.stop_sync()
110 
111 
112 class AsyncPlaywrightContextManager:
113     def __init__(self) -> None:
114         self._connection: Connection
115 
116     async def __aenter__(self) -> AsyncPlaywright:
117         self._connection = await run_driver_async()
118         self._connection.run_async()
119         playwright = AsyncPlaywright(
120             await self._connection.wait_for_object_with_known_name("Playwright")
121         )
122         playwright.stop = self.__aexit__  # type: ignore
123         return playwright
124 
125     async def start(self) -> AsyncPlaywright:
126         return await self.__aenter__()
127 
128     async def __aexit__(self, *args: Any) -> None:
129         self._connection.stop_async()
130 
131 
132 if sys.platform == "win32":
133     # Use ProactorEventLoop in 3.7, which is default in 3.8
134     loop = asyncio.ProactorEventLoop()
135     asyncio.set_event_loop(loop)
136 
137 
138 def main() -> None:
139     if "install" not in sys.argv:
140         print('Run "python -m playwright install" to complete installation')
141         return
142     driver_executable = compute_driver_executable()
143     # Fix the executable bit during the installation.
144     if not sys.platform == "win32":
145         st = os.stat(driver_executable)
146         if st.st_mode & stat.S_IEXEC == 0:
147             os.chmod(driver_executable, st.st_mode | stat.S_IEXEC)
148     print("Installing the browsers...")
149     subprocess.check_call([str(driver_executable), "install"])
150 
151     print("Playwright is now ready for use")
152
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/playwright/main.py b/playwright/main.py
--- a/playwright/main.py
+++ b/playwright/main.py
@@ -14,8 +14,6 @@
 
 import asyncio
 import io
-import os
-import stat
 import subprocess
 import sys
 from pathlib import Path
@@ -27,7 +25,7 @@
 from playwright.connection import Connection
 from playwright.helper import Error
 from playwright.object_factory import create_remote_object
-from playwright.path_utils import get_file_dirname
+from playwright.path_utils import get_file_dirname, make_file_executable
 from playwright.playwright import Playwright
 from playwright.sync_api import Playwright as SyncPlaywright
 from playwright.sync_base import dispatcher_fiber, set_dispatcher_fiber
@@ -37,15 +35,19 @@
     package_path = get_file_dirname()
     platform = sys.platform
     if platform == "darwin":
-        return package_path / "drivers" / "driver-darwin"
+        path = package_path / "drivers" / "driver-darwin"
+        return make_file_executable(path)
     elif platform == "linux":
-        return package_path / "drivers" / "driver-linux"
+        path = package_path / "drivers" / "driver-linux"
+        return make_file_executable(path)
     elif platform == "win32":
         result = package_path / "drivers" / "driver-win32-amd64.exe"
         if result.exists():
             return result
         return package_path / "drivers" / "driver-win32.exe"
-    return package_path / "drivers" / "driver-linux"
+
+    path = package_path / "drivers" / "driver-linux"
+    return make_file_executable(path)
 
 
 async def run_driver_async() -> Connection:
@@ -140,11 +142,7 @@
         print('Run "python -m playwright install" to complete installation')
         return
     driver_executable = compute_driver_executable()
-    # Fix the executable bit during the installation.
-    if not sys.platform == "win32":
-        st = os.stat(driver_executable)
-        if st.st_mode & stat.S_IEXEC == 0:
-            os.chmod(driver_executable, st.st_mode | stat.S_IEXEC)
+
     print("Installing the browsers...")
     subprocess.check_call([str(driver_executable), "install"])
 
diff --git a/playwright/path_utils.py b/playwright/path_utils.py
--- a/playwright/path_utils.py
+++ b/playwright/path_utils.py
@@ -1,4 +1,5 @@
 import inspect
+import stat
 from pathlib import Path
 
 
@@ -8,3 +9,9 @@
     module = inspect.getmodule(frame[0])
     assert module
     return Path(module.__file__).parent.absolute()
+
+
+def make_file_executable(file_path: Path) -> Path:
+    """Makes a file executable."""
+    file_path.chmod(file_path.stat().st_mode | stat.S_IEXEC)
+    return file_path

{"golden_diff": "diff --git a/playwright/main.py b/playwright/main.py\n--- a/playwright/main.py\n+++ b/playwright/main.py\n@@ -14,8 +14,6 @@\n \n import asyncio\n import io\n-import os\n-import stat\n import subprocess\n import sys\n from pathlib import Path\n@@ -27,7 +25,7 @@\n from playwright.connection import Connection\n from playwright.helper import Error\n from playwright.object_factory import create_remote_object\n-from playwright.path_utils import get_file_dirname\n+from playwright.path_utils import get_file_dirname, make_file_executable\n from playwright.playwright import Playwright\n from playwright.sync_api import Playwright as SyncPlaywright\n from playwright.sync_base import dispatcher_fiber, set_dispatcher_fiber\n@@ -37,15 +35,19 @@\n     package_path = get_file_dirname()\n     platform = sys.platform\n     if platform == \"darwin\":\n-        return package_path / \"drivers\" / \"driver-darwin\"\n+        path = package_path / \"drivers\" / \"driver-darwin\"\n+        return make_file_executable(path)\n     elif platform == \"linux\":\n-        return package_path / \"drivers\" / \"driver-linux\"\n+        path = package_path / \"drivers\" / \"driver-linux\"\n+        return make_file_executable(path)\n     elif platform == \"win32\":\n         result = package_path / \"drivers\" / \"driver-win32-amd64.exe\"\n         if result.exists():\n             return result\n         return package_path / \"drivers\" / \"driver-win32.exe\"\n-    return package_path / \"drivers\" / \"driver-linux\"\n+\n+    path = package_path / \"drivers\" / \"driver-linux\"\n+    return make_file_executable(path)\n \n \n async def run_driver_async() -> Connection:\n@@ -140,11 +142,7 @@\n         print('Run \"python -m playwright install\" to complete installation')\n         return\n     driver_executable = compute_driver_executable()\n-    # Fix the executable bit during the installation.\n-    if not sys.platform == \"win32\":\n-        st = os.stat(driver_executable)\n-        if st.st_mode & stat.S_IEXEC == 0:\n-            os.chmod(driver_executable, st.st_mode | stat.S_IEXEC)\n+\n     print(\"Installing the browsers...\")\n     subprocess.check_call([str(driver_executable), \"install\"])\n \ndiff --git a/playwright/path_utils.py b/playwright/path_utils.py\n--- a/playwright/path_utils.py\n+++ b/playwright/path_utils.py\n@@ -1,4 +1,5 @@\n import inspect\n+import stat\n from pathlib import Path\n \n \n@@ -8,3 +9,9 @@\n     module = inspect.getmodule(frame[0])\n     assert module\n     return Path(module.__file__).parent.absolute()\n+\n+\n+def make_file_executable(file_path: Path) -> Path:\n+    \"\"\"Makes a file executable.\"\"\"\n+    file_path.chmod(file_path.stat().st_mode | stat.S_IEXEC)\n+    return file_path\n", "issue": "Running playwright raises PermissionError on Linux\n### Reproducing the error\r\n\r\n- Created a virtual environment \r\n- Installed playwright with `python -m pip install playwright`\r\n\r\nTried to run some code\r\n\r\n```python\r\nfrom playwright import sync_playwright\r\n\r\nwith sync_playwright() as p:\r\n    for browser_type in [p.chromium, p.firefox, p.webkit]:\r\n        browser = browser_type.launch()\r\n        page = browser.newPage()\r\n        page.goto('http://whatsmyuseragent.org/')\r\n        page.screenshot(path=f'example-{browser_type.name}.png')\r\n        browser.close()\r\n```\r\n\r\nThen it raised this error\r\n\r\n```python\r\nPermissionError: [Errno 13] Permission denied: '/home/leno/Desktop/open-source/pwright/env/lib/python3.8/site-packages/playwright/drivers/driver-linux\r\n```\r\n\r\nI think this is not a normal behavior since running Python under sudo is a terrible idea.\r\n\r\n**OS**: Ubuntu 20.04\r\n**Python Version**: 3.8.2\r\n**Playwright Version**:  0.142.3\r\n\r\n\n", "before_files": [{"content": "import inspect\nfrom pathlib import Path\n\n\ndef get_file_dirname() -> Path:\n    \"\"\"Returns the callee (`__file__`) directory name\"\"\"\n    frame = inspect.stack()[1]\n    module = inspect.getmodule(frame[0])\n    assert module\n    return Path(module.__file__).parent.absolute()\n", "path": "playwright/path_utils.py"}, {"content": "# Copyright (c) Microsoft Corporation.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport asyncio\nimport io\nimport os\nimport stat\nimport subprocess\nimport sys\nfrom pathlib import Path\nfrom typing import Any\n\nfrom greenlet import greenlet\n\nfrom playwright.async_api import Playwright as AsyncPlaywright\nfrom playwright.connection import Connection\nfrom playwright.helper import Error\nfrom playwright.object_factory import create_remote_object\nfrom playwright.path_utils import get_file_dirname\nfrom playwright.playwright import Playwright\nfrom playwright.sync_api import Playwright as SyncPlaywright\nfrom playwright.sync_base import dispatcher_fiber, set_dispatcher_fiber\n\n\ndef compute_driver_executable() -> Path:\n    package_path = get_file_dirname()\n    platform = sys.platform\n    if platform == \"darwin\":\n        return package_path / \"drivers\" / \"driver-darwin\"\n    elif platform == \"linux\":\n        return package_path / \"drivers\" / \"driver-linux\"\n    elif platform == \"win32\":\n        result = package_path / \"drivers\" / \"driver-win32-amd64.exe\"\n        if result.exists():\n            return result\n        return package_path / \"drivers\" / \"driver-win32.exe\"\n    return package_path / \"drivers\" / \"driver-linux\"\n\n\nasync def run_driver_async() -> Connection:\n    driver_executable = compute_driver_executable()\n\n    # Sourced from: https://github.com/pytest-dev/pytest/blob/49827adcb9256c9c9c06a25729421dcc3c385edc/src/_pytest/faulthandler.py#L73-L80\n    def _get_stderr_fileno() -> int:\n        try:\n            return sys.stderr.fileno()\n        except io.UnsupportedOperation:\n            # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.\n            # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors\n            # This is potentially dangerous, but the best we can do.\n            return sys.__stderr__.fileno()\n\n    proc = await asyncio.create_subprocess_exec(\n        str(driver_executable),\n        stdin=asyncio.subprocess.PIPE,\n        stdout=asyncio.subprocess.PIPE,\n        stderr=_get_stderr_fileno(),\n        limit=32768,\n    )\n    assert proc.stdout\n    assert proc.stdin\n    connection = Connection(\n        proc.stdout, proc.stdin, create_remote_object, asyncio.get_event_loop()\n    )\n    return connection\n\n\ndef run_driver() -> Connection:\n    loop = asyncio.get_event_loop()\n    if loop.is_running():\n        raise Error(\"Can only run one Playwright at a time.\")\n    return loop.run_until_complete(run_driver_async())\n\n\nclass SyncPlaywrightContextManager:\n    def __init__(self) -> None:\n        self._connection = run_driver()\n        self._playwright: SyncPlaywright\n\n    def __enter__(self) -> SyncPlaywright:\n        g_self = greenlet.getcurrent()\n\n        def callback_wrapper(playwright_impl: Playwright) -> None:\n            self._playwright = SyncPlaywright(playwright_impl)\n            g_self.switch()\n\n        self._connection.call_on_object_with_known_name(\"Playwright\", callback_wrapper)\n        set_dispatcher_fiber(greenlet(lambda: self._connection.run_sync()))\n        dispatcher_fiber().switch()\n        playwright = self._playwright\n        playwright.stop = self.__exit__  # type: ignore\n        return playwright\n\n    def start(self) -> SyncPlaywright:\n        return self.__enter__()\n\n    def __exit__(self, *args: Any) -> None:\n        self._connection.stop_sync()\n\n\nclass AsyncPlaywrightContextManager:\n    def __init__(self) -> None:\n        self._connection: Connection\n\n    async def __aenter__(self) -> AsyncPlaywright:\n        self._connection = await run_driver_async()\n        self._connection.run_async()\n        playwright = AsyncPlaywright(\n            await self._connection.wait_for_object_with_known_name(\"Playwright\")\n        )\n        playwright.stop = self.__aexit__  # type: ignore\n        return playwright\n\n    async def start(self) -> AsyncPlaywright:\n        return await self.__aenter__()\n\n    async def __aexit__(self, *args: Any) -> None:\n        self._connection.stop_async()\n\n\nif sys.platform == \"win32\":\n    # Use ProactorEventLoop in 3.7, which is default in 3.8\n    loop = asyncio.ProactorEventLoop()\n    asyncio.set_event_loop(loop)\n\n\ndef main() -> None:\n    if \"install\" not in sys.argv:\n        print('Run \"python -m playwright install\" to complete installation')\n        return\n    driver_executable = compute_driver_executable()\n    # Fix the executable bit during the installation.\n    if not sys.platform == \"win32\":\n        st = os.stat(driver_executable)\n        if st.st_mode & stat.S_IEXEC == 0:\n            os.chmod(driver_executable, st.st_mode | stat.S_IEXEC)\n    print(\"Installing the browsers...\")\n    subprocess.check_call([str(driver_executable), \"install\"])\n\n    print(\"Playwright is now ready for use\")\n", "path": "playwright/main.py"}], "after_files": [{"content": "import inspect\nimport stat\nfrom pathlib import Path\n\n\ndef get_file_dirname() -> Path:\n    \"\"\"Returns the callee (`__file__`) directory name\"\"\"\n    frame = inspect.stack()[1]\n    module = inspect.getmodule(frame[0])\n    assert module\n    return Path(module.__file__).parent.absolute()\n\n\ndef make_file_executable(file_path: Path) -> Path:\n    \"\"\"Makes a file executable.\"\"\"\n    file_path.chmod(file_path.stat().st_mode | stat.S_IEXEC)\n    return file_path\n", "path": "playwright/path_utils.py"}, {"content": "# Copyright (c) Microsoft Corporation.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport asyncio\nimport io\nimport subprocess\nimport sys\nfrom pathlib import Path\nfrom typing import Any\n\nfrom greenlet import greenlet\n\nfrom playwright.async_api import Playwright as AsyncPlaywright\nfrom playwright.connection import Connection\nfrom playwright.helper import Error\nfrom playwright.object_factory import create_remote_object\nfrom playwright.path_utils import get_file_dirname, make_file_executable\nfrom playwright.playwright import Playwright\nfrom playwright.sync_api import Playwright as SyncPlaywright\nfrom playwright.sync_base import dispatcher_fiber, set_dispatcher_fiber\n\n\ndef compute_driver_executable() -> Path:\n    package_path = get_file_dirname()\n    platform = sys.platform\n    if platform == \"darwin\":\n        path = package_path / \"drivers\" / \"driver-darwin\"\n        return make_file_executable(path)\n    elif platform == \"linux\":\n        path = package_path / \"drivers\" / \"driver-linux\"\n        return make_file_executable(path)\n    elif platform == \"win32\":\n        result = package_path / \"drivers\" / \"driver-win32-amd64.exe\"\n        if result.exists():\n            return result\n        return package_path / \"drivers\" / \"driver-win32.exe\"\n\n    path = package_path / \"drivers\" / \"driver-linux\"\n    return make_file_executable(path)\n\n\nasync def run_driver_async() -> Connection:\n    driver_executable = compute_driver_executable()\n\n    # Sourced from: https://github.com/pytest-dev/pytest/blob/49827adcb9256c9c9c06a25729421dcc3c385edc/src/_pytest/faulthandler.py#L73-L80\n    def _get_stderr_fileno() -> int:\n        try:\n            return sys.stderr.fileno()\n        except io.UnsupportedOperation:\n            # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.\n            # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors\n            # This is potentially dangerous, but the best we can do.\n            return sys.__stderr__.fileno()\n\n    proc = await asyncio.create_subprocess_exec(\n        str(driver_executable),\n        stdin=asyncio.subprocess.PIPE,\n        stdout=asyncio.subprocess.PIPE,\n        stderr=_get_stderr_fileno(),\n        limit=32768,\n    )\n    assert proc.stdout\n    assert proc.stdin\n    connection = Connection(\n        proc.stdout, proc.stdin, create_remote_object, asyncio.get_event_loop()\n    )\n    return connection\n\n\ndef run_driver() -> Connection:\n    loop = asyncio.get_event_loop()\n    if loop.is_running():\n        raise Error(\"Can only run one Playwright at a time.\")\n    return loop.run_until_complete(run_driver_async())\n\n\nclass SyncPlaywrightContextManager:\n    def __init__(self) -> None:\n        self._connection = run_driver()\n        self._playwright: SyncPlaywright\n\n    def __enter__(self) -> SyncPlaywright:\n        g_self = greenlet.getcurrent()\n\n        def callback_wrapper(playwright_impl: Playwright) -> None:\n            self._playwright = SyncPlaywright(playwright_impl)\n            g_self.switch()\n\n        self._connection.call_on_object_with_known_name(\"Playwright\", callback_wrapper)\n        set_dispatcher_fiber(greenlet(lambda: self._connection.run_sync()))\n        dispatcher_fiber().switch()\n        playwright = self._playwright\n        playwright.stop = self.__exit__  # type: ignore\n        return playwright\n\n    def start(self) -> SyncPlaywright:\n        return self.__enter__()\n\n    def __exit__(self, *args: Any) -> None:\n        self._connection.stop_sync()\n\n\nclass AsyncPlaywrightContextManager:\n    def __init__(self) -> None:\n        self._connection: Connection\n\n    async def __aenter__(self) -> AsyncPlaywright:\n        self._connection = await run_driver_async()\n        self._connection.run_async()\n        playwright = AsyncPlaywright(\n            await self._connection.wait_for_object_with_known_name(\"Playwright\")\n        )\n        playwright.stop = self.__aexit__  # type: ignore\n        return playwright\n\n    async def start(self) -> AsyncPlaywright:\n        return await self.__aenter__()\n\n    async def __aexit__(self, *args: Any) -> None:\n        self._connection.stop_async()\n\n\nif sys.platform == \"win32\":\n    # Use ProactorEventLoop in 3.7, which is default in 3.8\n    loop = asyncio.ProactorEventLoop()\n    asyncio.set_event_loop(loop)\n\n\ndef main() -> None:\n    if \"install\" not in sys.argv:\n        print('Run \"python -m playwright install\" to complete installation')\n        return\n    driver_executable = compute_driver_executable()\n\n    print(\"Installing the browsers...\")\n    subprocess.check_call([str(driver_executable), \"install\"])\n\n    print(\"Playwright is now ready for use\")\n", "path": "playwright/main.py"}]}