From ad27de77172bc645a06b38742a70e9518ba44fa0 Mon Sep 17 00:00:00 2001 From: uael Date: Fri, 10 Feb 2023 20:10:59 +0000 Subject: [PATCH] device: remove "feature" which enable accept to return the same connection has connect --- bumble/device.py | 12 +----------- tests/device_test.py | 5 +---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/bumble/device.py b/bumble/device.py index b5137c6..a971391 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -1827,7 +1827,7 @@ class Device(CompositeEventEmitter): set. Notes: - * A `connect` to the same peer will also complete this call. + * A `connect` to the same peer will not complete this call. * The `timeout` parameter is only handled while waiting for the connection request, once received and accepted, the controller shall issue a connection complete event. @@ -2409,16 +2409,6 @@ class Device(CompositeEventEmitter): ) self.connections[connection_handle] = connection - # We may have an accept ongoing waiting for a connection request for - # `peer_address`. - # Typically happen when using `connect` to the same `peer_address` we are - # waiting for with an `accept`. - # In this case, set the completed `connection` to the `accept` future - # result. - if peer_address in self.classic_pending_accepts: - future, *_ = self.classic_pending_accepts.pop(peer_address) - future.set_result(connection) - # Emit an event to notify listeners of the new connection self.emit('connection', connection) else: diff --git a/tests/device_test.py b/tests/device_test.py index 07aecdd..1bcd0d0 100644 --- a/tests/device_test.py +++ b/tests/device_test.py @@ -197,7 +197,7 @@ async def test_device_connect_parallel(): d1.host.set_packet_sink(Sink(d1_flow())) d2.host.set_packet_sink(Sink(d2_flow())) - [c01, c02, a10, a20, a01] = await asyncio.gather( + [c01, c02, a10, a20] = await asyncio.gather( *[ asyncio.create_task( d0.connect(d1.public_address, transport=BT_BR_EDR_TRANSPORT) @@ -207,7 +207,6 @@ async def test_device_connect_parallel(): ), asyncio.create_task(d1.accept(peer_address=d0.public_address)), asyncio.create_task(d2.accept()), - asyncio.create_task(d0.accept(peer_address=d1.public_address)), ] ) @@ -215,11 +214,9 @@ async def test_device_connect_parallel(): assert type(c02) == Connection assert type(a10) == Connection assert type(a20) == Connection - assert type(a01) == Connection assert c01.handle == a10.handle and c01.handle == 0x100 assert c02.handle == a20.handle and c02.handle == 0x101 - assert a01 == c01 # -----------------------------------------------------------------------------