Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions a_sync/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from asyncio import sleep
from asyncio.futures import _convert_future_exc
from concurrent.futures import _base, thread
from functools import cached_property

from a_sync._typing import *
from a_sync.primitives._debug import _DebugDaemonMixin
Expand Down Expand Up @@ -206,6 +207,16 @@ def worker_count_current(self) -> int:
"""
return len(getattr(self, f"_{self._workers}"))

@cached_property
def _create_future(self) -> Callable[[], asyncio.Future]:
# This helper lets us defer getting the loop during init so the user can set a different one
return self._get_loop().create_future

@cached_property
def _call_soon_threadsafe(self) -> Callable[..., asyncio.TimerHandle]:
# This helper lets us defer getting the loop during init so the user can set a different one
return self._get_loop().call_soon_threadsafe

def __init_mixin__(self):
self.sync_mode = self._max_workers == 0
self.__super_submit = super().submit
Expand Down
Loading