|
9 | 9 | import ssl
|
10 | 10 | import struct
|
11 | 11 | import urllib.parse
|
12 |
| -from typing import List, Optional |
| 12 | +from typing import List |
13 | 13 |
|
14 | 14 | import trio
|
15 | 15 | import trio.abc
|
@@ -744,10 +744,9 @@ def __init__(self, stream, ws_connection, *, host=None, path=None,
|
744 | 744 | # Set once a WebSocket closed handshake takes place, i.e after a close
|
745 | 745 | # frame has been sent and a close frame has been received.
|
746 | 746 | self._close_handshake = trio.Event()
|
747 |
| - # When not None, set immediately upon receiving CloseConnection from peer, |
748 |
| - # followed by sleep(0) for a context switch. Used to test close race |
749 |
| - # conditions between client and server. |
750 |
| - self._for_testing_peer_closed_connection: Optional[trio.Event] = None |
| 747 | + # Set upon receiving CloseConnection from peer. |
| 748 | + # Used to test close race conditions between client and server. |
| 749 | + self._for_testing_peer_closed_connection = trio.Event() |
751 | 750 |
|
752 | 751 | @property
|
753 | 752 | def closed(self):
|
@@ -1105,9 +1104,7 @@ async def _handle_close_connection_event(self, event):
|
1105 | 1104 | # Set _close_reason in advance, so that send_message() will raise
|
1106 | 1105 | # ConnectionClosed during the close handshake.
|
1107 | 1106 | self._close_reason = CloseReason(event.code, event.reason or None)
|
1108 |
| - if self._for_testing_peer_closed_connection: |
1109 |
| - self._for_testing_peer_closed_connection.set() |
1110 |
| - await trio.sleep(0) |
| 1107 | + self._for_testing_peer_closed_connection.set() |
1111 | 1108 | await self._send(event.response())
|
1112 | 1109 | await self._close_web_socket(event.code, event.reason or None)
|
1113 | 1110 | self._close_handshake.set()
|
|
0 commit comments