Skip to content

Commit

Permalink
futurequeue: Apply black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sjlongland committed May 26, 2024
1 parent cd1e525 commit 1f8e739
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aioax25/futurequeue.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from functools import partial


class FutureQueue(object):
"""
A future queue is a helper for managing multiple Future objects that may
Expand All @@ -15,6 +16,7 @@ class FutureQueue(object):
added to it. When the operation completes or fails, all added futures
are notified.
"""

def __init__(self, threadsafe=False):
self._threadsafe = threadsafe
self._futures = []
Expand All @@ -34,20 +36,23 @@ def add(self, future, threadsafe=None):
def cancel(self, *args, **kwargs):
def _cancel(future):
future.cancel(*args, **kwargs)

self._foreach_future(_cancel)

def set_exception(self, *args, **kwargs):
def _set_exception(future):
future.set_exception(*args, **kwargs)

self._foreach_future(_set_exception)

def set_result(self, *args, **kwargs):
def _set_result(future):
future.set_result(*args, **kwargs)

self._foreach_future(_set_result)

def _foreach_future(self, action):
for (future, call_soon) in self._futures:
for future, call_soon in self._futures:
if future.done():
continue
call_soon(partial(action, future))

0 comments on commit 1f8e739

Please sign in to comment.