Skip to content

Commit

Permalink
Fix race condition on connections
Browse files Browse the repository at this point in the history
  • Loading branch information
PandaWill committed Aug 27, 2020
1 parent 59a8c64 commit f1b30cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ async def connect(self, req: 'ClientRequest',
key = req.connection_key
available = self._available_connections(key)

# Wait if there are no available connections.
if available <= 0:
# Wait if there are no available connections or if there are/were
# waiters (i.e. don't steal connection from a waiter about to wake up)
if available <= 0 or key in self._waiters:
fut = self._loop.create_future()

# This connection will now count towards the limit.
Expand Down
1 change: 0 additions & 1 deletion tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,6 @@ def check_with_exc(err):
check_with_exc(asyncio.TimeoutError())


@pytest.mark.xfail
async def test_connect_with_limit_concurrent(loop) -> None:
proto = create_mocked_conn(loop)
proto.should_close = False
Expand Down

0 comments on commit f1b30cc

Please sign in to comment.