Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit fd66a58

Browse files
authored
Merge pull request #276 from plucury/development
Reset connection state when it was closed even its _sock object is None
2 parents 2146b71 + 4256291 commit fd66a58

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: hyper/http20/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def close(self, error_code=None):
450450

451451
if self._sock is not None:
452452
self._sock.close()
453-
self.__init_state()
453+
self.__init_state()
454454

455455
def _send_outstanding_data(self, tolerate_peer_gone=False,
456456
send_empty=True):

Diff for: test/test_hyper.py

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import h2.settings
33

44
from h2.frame_buffer import FrameBuffer
5+
from h2.connection import ConnectionState
56
from hyperframe.frame import (
67
Frame, DataFrame, RstStreamFrame, SettingsFrame, PushPromiseFrame,
78
WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame,
@@ -275,6 +276,19 @@ def test_closed_connections_are_reset(self):
275276
assert c.recent_stream is None
276277
assert c.next_stream_id == 1
277278
assert c.window_manager is not wm
279+
with c._conn as conn:
280+
assert conn.state_machine.state == ConnectionState.IDLE
281+
origin_h2_conn = conn
282+
283+
c.close()
284+
assert c._sock is None
285+
assert not c.streams
286+
assert c.recent_stream is None
287+
assert c.next_stream_id == 1
288+
assert c.window_manager is not wm
289+
with c._conn as conn:
290+
assert conn.state_machine.state == ConnectionState.IDLE
291+
assert conn != origin_h2_conn
278292

279293
def test_streams_removed_on_close(self):
280294
# Create content for read from socket

0 commit comments

Comments
 (0)