mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
address PR comments
This commit is contained in:
@@ -1245,7 +1245,7 @@ class Device(CompositeEventEmitter):
|
||||
|
||||
async def power_off(self) -> None:
|
||||
if self.powered_on:
|
||||
await self.host.reset()
|
||||
await self.host.flush()
|
||||
self.powered_on = False
|
||||
|
||||
# TODO: more cleanup
|
||||
|
||||
@@ -20,7 +20,7 @@ import logging
|
||||
import traceback
|
||||
import collections
|
||||
import sys
|
||||
from typing import Awaitable, TypeVar
|
||||
from typing import Awaitable, Set, TypeVar
|
||||
from functools import wraps
|
||||
from pyee import EventEmitter
|
||||
|
||||
@@ -157,6 +157,9 @@ class AsyncRunner:
|
||||
# Shared default queue
|
||||
default_queue = WorkQueue()
|
||||
|
||||
# Shared set of running tasks
|
||||
running_tasks: Set[Awaitable] = set()
|
||||
|
||||
@staticmethod
|
||||
def run_in_task(queue=None):
|
||||
"""
|
||||
@@ -187,6 +190,19 @@ class AsyncRunner:
|
||||
|
||||
return decorator
|
||||
|
||||
@staticmethod
|
||||
def run(coroutine):
|
||||
"""
|
||||
Create a task to run a coroutine in a "fire and forget" task.
|
||||
|
||||
Using this method instead of just calling `asyncio.create_task(coroutine)`
|
||||
is necessary when you don't keep a reference to the task, because `asyncio`
|
||||
only keeps weak references to alive tasks.
|
||||
"""
|
||||
task = asyncio.create_task(coroutine)
|
||||
AsyncRunner.running_tasks.add(task)
|
||||
task.add_done_callback(AsyncRunner.running_tasks.remove)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
class FlowControlAsyncPipe:
|
||||
|
||||
Reference in New Issue
Block a user