Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dead Connection.detach() and Connection.writer #3358

Merged
merged 3 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/3358.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop dead ``Connection.detach()`` and ``Connection.writer``. Both methods were broken
for more than 2 years.
11 changes: 0 additions & 11 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ def transport(self):
def protocol(self):
return self._protocol

@property
def writer(self):
return self._protocol.writer

def add_callback(self, callback):
if callback is not None:
self._callbacks.append(callback)
Expand Down Expand Up @@ -119,13 +115,6 @@ def release(self):
should_close=self._protocol.should_close)
self._protocol = None

def detach(self):
self._notify_release()

if self._protocol is not None:
self._connector._release_acquired(self._protocol)
self._protocol = None

@property
def closed(self):
return self._protocol is None or not self._protocol.is_connected()
Expand Down
7 changes: 0 additions & 7 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1062,13 +1062,6 @@ Connection
later if timeout (30 seconds by default) for connection was not
expired.

.. method:: detach()

Detach underlying socket from connection.

Underlying socket is not closed, next :meth:`close` or
:meth:`release` calls don't return socket to free pool.


Response object
---------------
Expand Down
33 changes: 0 additions & 33 deletions tests/test_client_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_ctor(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
assert conn.loop is loop
assert conn.protocol is protocol
assert conn.writer is protocol.writer
conn.close()


Expand Down Expand Up @@ -65,19 +64,6 @@ def cb():
assert notified


def test_callbacks_on_detach(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
notified = False

def cb():
nonlocal notified
notified = True

conn.add_callback(cb)
conn.detach()
assert notified


def test_callbacks_exception(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
notified = False
Expand Down Expand Up @@ -151,22 +137,3 @@ def test_release_released(connector, key, protocol, loop) -> None:
assert not protocol.transport.close.called
assert conn._protocol is None
assert not connector._release.called


def test_detach(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
assert not conn.closed
conn.detach()
assert conn._protocol is None
assert connector._release_acquired.called
assert not connector._release.called
assert conn.closed


def test_detach_closed(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
conn.release()
conn.detach()

assert not connector._release_acquired.called
assert conn._protocol is None
11 changes: 0 additions & 11 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ def test_connection_del_loop_closed(loop) -> None:
assert not exc_handler.called


def test_connection_detach(loop) -> None:
connector = mock.Mock()
key = mock.Mock()
protocol = mock.Mock()
conn = Connection(connector, key, protocol, loop=loop)
conn._notify_release = mock.Mock()
conn.detach()
assert conn._notify_release.called
connector._release_acquired.assert_called_with(protocol)


def test_del(loop) -> None:
conn = aiohttp.BaseConnector(loop=loop)
proto = mock.Mock(should_close=False)
Expand Down