# glance.async_ package

## Subpackages

- glance.async_.flows package
  - Subpackages
    - glance.async_.flows.plugins package
      - Submodules
      - Module contents
  - Submodules
    - glance.async_.flows.api_image_import module
    - glance.async_.flows.base_import module
    - glance.async_.flows.convert module
    - glance.async_.flows.introspect module
    - glance.async_.flows.ovf_process module
  - Module contents

## Submodules

- glance.async_.taskflow_executor module
- glance.async_.utils module

## Module contents

class glance.async_.EventletThreadPoolModel(size=None)

  Bases: `glance.async_.ThreadPoolModel`

  A ThreadPoolModel suitable for use with evenlet/greenthreads.

  DEFAULTSIZE = 1024
  static get_threadpool_executor_class()

    Returns a futurist.ThreadPoolExecutor class.

class glance.async_.NativeThreadPoolModel(size=None)

  Bases: `glance.async_.ThreadPoolModel`

  A ThreadPoolModel suitable for use with native threads.

  DEFAULTSIZE = 16
  static get_threadpool_executor_class()

    Returns a futurist.ThreadPoolExecutor class.

class glance.async_.TaskExecutor(context, task_repo, image_repo, image_factory, admin_repo=None)

  Bases: `object`

  Base class for Asynchronous task executors. It does not support the execution mechanism.

  Provisions the extensible classes with necessary variables to utilize important Glance modules like, context, task_repo, image_repo, image_factory.

  Note:

    It also gives abstraction for the standard pre-processing and post-processing operations to be executed by a task. These may include validation checks, security checks, introspection, error handling etc. The aim is to give developers an abstract sense of the execution pipeline logic.

  Args:
    context: glance.context.RequestContext object for AuthZ and AuthN

      checks

    task_repo: glance.db.TaskRepo object which acts as a translator for

      glance.domain.Task and glance.domain.TaskStub objects into ORM semantics

    image_repo: glance.db.ImageRepo object which acts as a translator for

      glance.domain.Image object into ORM semantics

    image_factory: glance.domain.ImageFactory object to be used for

      creating new images for certain types of tasks viz. import, cloning

    admin_repo: glance.db.ImageRepo object which acts as a translator for

      glance.domain.Image object into ORM semantics, but with an admin context (optional)

  begin_processing(task_id)

class glance.async_.ThreadPoolModel(size=None)

  Bases: `object`

  Base class for an abstract ThreadPool.

  Do not instantiate this directly, use one of the concrete implementations.

  DEFAULTSIZE = 1
  static get_threadpool_executor_class()

    Returns a futurist.ThreadPoolExecutor class.

  map(fn, iterable)

    Map a function to each value in an iterable.

    This spawns a thread for each item in the provided iterable, generating results in the same order. Each item will spawn a thread, and each may run in parallel up to the limit of the pool.

    Parameters

      - fn – A function to work on each item

      - iterable – A sequence of items to process

    Returns

      A generator of results in the same order

  spawn(fn, *args, **kwargs)

    Spawn a function with args using the thread pool.

glance.async_.get_threadpool_model()

  Returns the system-wide threadpool model class.

  This must be called after set_threadpool_model() whenever some code needs to know what the threadpool implementation is.

  This may only be called after set_threadpool_model() has been called to set the desired threading mode. If it is called before the model is set, it will raise AssertionError. This would likely be the case if this got run in a test before the model was initialized, or if glance modules that use threading were imported and run from some other code without setting the model first.

  Raises

    AssertionError if the model has not yet been set.

glance.async_.set_threadpool_model(thread_type)

  Set the system-wide threadpool model.

  This sets the type of ThreadPoolModel to use globally in the process. It should be called very early in init, and only once.

  Parameters

    thread_type – A string indicating the threading type in use, either “eventlet” or “native”

  Raises

    RuntimeError if the model is already set or some thread_type other than one of the supported ones is provided.

this page last updated: 2026-03-19 02:17:34

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug