cmeta.core_async module

CMeta asynchronous wrapper for the core class

cMeta author and developer: (C) 2025-2026 Grigori Fursin

See the cMeta COPYRIGHT and LICENSE files in the project root for details.

Classes

class cmeta.core_async.CMetaAsync(max_workers=None, logger=None, loop=None, **kwargs)[source]

Bases: CMeta

Async wrapper around CMeta using multiprocessing for non-blocking operations.

This class extends CMeta to provide asynchronous wrappers around blocking operations using a ProcessPoolExecutor. It prevents blocking the event loop in FastAPI or other asyncio-based services by executing CMeta operations in separate worker processes.

Inherits all CMeta methods while providing async wrappers for blocking operations.

__init__(max_workers=None, logger=None, loop=None, **kwargs)[source]

Initialize CMetaAsync with process pool executor.

Parameters:
  • max_workers – Maximum number of worker processes in the pool. If None, defaults to ProcessPoolExecutor’s default.

  • logger – Custom logger instance. If None, uses parent CMeta’s logger.

  • loop – Event loop to use. If None, gets the current event loop.

  • **kwargs – Additional keyword arguments passed to CMeta constructor.

async access(params)[source]

Asynchronous non-blocking wrapper for CMeta.access().

Runs CMeta.access() in a worker process to avoid blocking the event loop.

Parameters:

params – Dictionary of parameters to pass to CMeta.access().

Returns:

Result dictionary from CMeta.access() with ‘return’ and other keys.

Return type:

dict

access_sync(params)[source]

Synchronous access using the inherited CMeta.access() method.

Use this method when already executing in a worker thread or process where blocking is acceptable.

Parameters:

params – Dictionary of parameters to pass to CMeta.access().

Returns:

Result dictionary from CMeta.access().

Return type:

dict

shutdown()[source]

Gracefully shutdown the process pool executor.

Waits for all pending tasks to complete before shutting down the executor. This method can be tied to FastAPI or other framework shutdown events.