[3.7] Revert "bpo-36801: Fix waiting in StreamWriter.drain for closing SSL transport (GH-13098)" by vstinner · Pull Request #13328 · python/cpython (original) (raw)

Without this change, I easily reproduce the failure on Windows:

vstinner@WIN C:\vstinner\python\3.7>python -m test test_asyncio -m test_drain_raises -v
(...)
test_drain_raises (test.test_asyncio.test_streams.StreamTests) ... Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 2)     
Dangling thread: <Thread(Thread-1, stopped daemon 1568)>
Dangling thread: <_MainThread(MainThread, started 1244)>
ERROR

======================================================================
ERROR: test_drain_raises (test.test_asyncio.test_streams.StreamTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\vstinner\python\3.7\lib\test\test_asyncio\test_streams.py", line 820, in test_drain_raises
    self.loop.run_until_complete(client(*addr))
  File "C:\vstinner\python\3.7\lib\asyncio\base_events.py", line 584, in run_until_complete
    return future.result()
  File "C:\vstinner\python\3.7\lib\test\test_asyncio\test_streams.py", line 810, in client
    await writer.drain()
  File "C:\vstinner\python\3.7\lib\asyncio\streams.py", line 351, in drain
    await fut
  File "C:\vstinner\python\3.7\lib\asyncio\selector_events.py", line 860, in write
    n = self._sock.send(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
(...)

With this change, the test pass as expected:

vstinner@WIN C:\vstinner\python\3.7>python -m test test_asyncio -m test_drain_raises -v
(...)
test_drain_raises (test.test_asyncio.test_streams.StreamTests) ... ok
(...)
Tests result: SUCCESS