Skip to content

flowmachine.core.context

Source: flowmachine/core/context.py

Context variables for Flowmachine to talk to FlowDB and Redis, and a common thread pool for managing queries.

bind_context

bind_context(connection: flowmachine.core.connection.Connection, executor_pool: concurrent.futures._base.Executor, redis_conn: redis.client.Redis)
Source: flowmachine/core/context.py

Set the current context's connection, executor and redis connection, replacing any that were previously set.

Parameters

  • connection: flowmachine.core.connection.Connection

    Connection to set

  • executor_pool: concurrent.futures._base.Executor

    Executor to be the new pool

  • redis_conn: redis.client.Redis

    Redis client

context

context(connection: flowmachine.core.connection.Connection, executor_pool: concurrent.futures._base.Executor, redis_conn: redis.client.Redis)
Source: flowmachine/core/context.py

Context manager which can be used to temporarily provide a connection, redis client and pool.

Parameters

  • connection: flowmachine.core.connection.Connection

    Connection which will be used within this context

  • executor_pool: concurrent.futures._base.Executor

    Executor pool which will be used within this context

  • redis_conn: redis.client.Redis

    Redis client which will be used within this context

get_db

get_db() -> flowmachine.core.connection.Connection
Source: flowmachine/core/context.py

Get the current context's database connection.

Returns

  • flowmachine.core.connection.Connection

get_executor

get_executor() -> concurrent.futures._base.Executor
Source: flowmachine/core/context.py

Get the current context's executor pool.

Returns

  • concurrent.futures._base.Executor

get_redis

get_redis() -> redis.client.Redis
Source: flowmachine/core/context.py

Get the current context's redis client.

Returns

  • redis.client.Redis

submit_to_executor

submit_to_executor(func: Callable, *args, **kwargs) -> concurrent.futures._base.Future
Source: flowmachine/core/context.py

Submit a callable to the current context's executor pool and get back a future to monitor execution.

Parameters

  • func: typing.Callable

    Callable to be executed

  • args

    Positional arguments to func

  • kwargs

    Keyword arguments to func

Returns

  • concurrent.futures._base.Future