Skip to main content
Version: devel

extract.concurrency

FuturesPool Objects

class FuturesPool()

[view_source]

Worker pool for pipe items that can be resolved asynchronously.

Items can be either asyncio coroutines or regular callables which will be executed in a thread pool.

submit

def submit(pipe_item: ResolvablePipeItem) -> TItemFuture

[view_source]

Submit an item to the pool.

Arguments:

  • pipe_item - The pipe item to submit. pipe_item.item must be either an asyncio coroutine or a callable.

Returns:

The resulting future object

resolve_next_future

def resolve_next_future(
use_configured_timeout: bool = False) -> Optional[ResolvablePipeItem]

[view_source]

Block until the next future is done and return the result. Returns None if no futures done.

Arguments:

  • use_configured_timeout - If True, use the value of self.poll_interval as the max wait time, raises concurrent.futures.TimeoutError if no future is done within that time.

Returns:

The resolved future item or None if no future is done.

resolve_next_future_no_wait

def resolve_next_future_no_wait() -> Optional[ResolvablePipeItem]

[view_source]

Resolve the first done future in the pool. This does not block and returns None if no future is done.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.