Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
remove unused task in CoreBluetooth backend
Browse files Browse the repository at this point in the history
The _central_manager_delegate_ready task doesn't appear to do anything
useful (not used by anything) and it may never finish which can cause
an error when an application exits.

Task was destroyed but it is pending!
task: <Task pending name='Task-2' coro=<Application._central_manager_delegate_ready() running at bleak/backends/corebluetooth/__init__.py:46>>
  • Loading branch information
dlech committed Jun 18, 2020
1 parent 9c87ac0 commit 26ab00f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
7 changes: 0 additions & 7 deletions bleak/backends/corebluetooth/CentralManagerDelegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ def enabled(self):
def isConnected(self) -> bool:
return self._connection_state == CMDConnectionState.CONNECTED

async def is_ready(self):
"""is_ready allows an asynchronous way to wait and ensure the
CentralManager has processed it's inputs before moving on"""
while not self.ready:
await asyncio.sleep(0)
return self.ready

async def scanForPeripherals_(self, scan_options) -> List[CBPeripheral]:
"""
Scan for peripheral devices
Expand Down
4 changes: 0 additions & 4 deletions bleak/backends/corebluetooth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Application:
def __init__(self):
self.main_loop = asyncio.get_event_loop()
self.main_loop.create_task(self._handle_nsrunloop())
self.main_loop.create_task(self._central_manager_delegate_ready())

self.nsrunloop = NSRunLoop.currentRunLoop()

Expand All @@ -43,9 +42,6 @@ async def _handle_nsrunloop(self):
self.nsrunloop.runMode_beforeDate_(NSDefaultRunLoopMode, time_interval)
await asyncio.sleep(0)

async def _central_manager_delegate_ready(self):
await self.central_manager_delegate.is_ready()


# Restructure this later: Global isn't the prettiest way of doing this...
global CBAPP
Expand Down

0 comments on commit 26ab00f

Please sign in to comment.