Repository: microsoft/playwright-python

Issue:
Async API - asyncio error
After updating to the 1.9.2 version, for **Async API** I get the following error:

Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000000002E1E9D0>
Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_subprocess.py", line 126, in __del__
    self.close()
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_subprocess.py", line 104, in close  
    proto.pipe.close()
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close  
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000000002E4A280>
Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Versions:
playwright=1.9.2
asyncio=3.4.3


Discussion:
I also see this pop up frequently, not sure if it is my implementation or PW:

```
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7f2216193a60>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 126, in __del__
    self.close()
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 536, in close
    self._close(None)
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 560, in _close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 719, in call_soon
    self._check_closed()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7f2216193a60>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 126, in __del__
    self.close()
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 536, in close
    self._close(None)
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 560, in _close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 719, in call_soon
    self._check_closed()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
```

same versions as @all4me7 
@all4me7 which version did you use before where it didn't occur? 
@mxschmitt Before, I was using version 1.8.0a1. 

Resolving patch:
diff --git a/playwright/_impl/_transport.py b/playwright/_impl/_transport.py
--- a/playwright/_impl/_transport.py
+++ b/playwright/_impl/_transport.py
@@ -48,12 +48,13 @@ def stop(self) -> None:
 
     async def wait_until_stopped(self) -> None:
         await self._stopped_future
+        await self._proc.wait()
 
     async def run(self) -> None:
         self._loop = asyncio.get_running_loop()
         self._stopped_future: asyncio.Future = asyncio.Future()
 
-        proc = await asyncio.create_subprocess_exec(
+        self._proc = proc = await asyncio.create_subprocess_exec(
             str(self._driver_executable),
             "run-driver",
             stdin=asyncio.subprocess.PIPE,


Test patch: