_images/ExtremeSwitchingLogo.png _images/XosLogo.png

The EXOS Python API

The EXOS Python API provides a high-level interface to EXOS functionality. It is part of the EXOS SDK, which allows third-parties and customers to develop native applications which extend the functionality of EXOS.

To create the EXOS Python API, the EXOS C API was bound into Python. As such, in some cases, the Python API is a reflection of the C API. However, where appropriate, a more high-level, Python-ish, and object-oriented API is presented. The goal is for a Python developer to feel at home, while still allowing full access to EXOS functionality.

To use the EXOS Python API, import it as follows:

from exos import api

The following sections discuss the API.

References.

Runtime Environment

Python applications can be run on EXOS by:

  1. Using the create process command, which is documented in the EXOS User Guide.
  2. Installing an XMOD. For more information about creating an XMOD, contact Extreme.

Python applications are run in a “Python container” known as EXPY. It implements the EXOS Python API and provides the Python runtime environment.

Threading Models

The EXOS C API is generally asynchronous. Requests are sent and responses are returned via a callback. Calls are non-blocking, allowing a thread to do other work instead of waiting for the response. This enables an efficient single-threaded processing model. However, asynchronous calls are arguably more complicated to develop and use.

Many developers, particularly developers of high-level languages such as Python, are more comfortable with a synchronous API where calls block until the response is received. Such an API will typically require an application to be multi-threaded.

In most cases, the EXOS Python API will provide both an asynchronous and a synchronous version of each call. We strongly discourage mixing asynchronous and synchronous calls, which will usually result in a deadlock. EXPY will attempt to detect a deadlock before it happens and raise DeadlockDetectedError instead.

The Python application is launched in a Runner thread, leaving the main thread to interact with EXOS. The application can exit the runtime environment using sys.exit() or thread.exit() from the Runner thread. These will raise a SystemExit exception, allowing clean-up handlers, such as finally blocks, to run. The application can also exit from any thread using os._exit(), but clean-up handlers will not be run.

If the Runner thread exits, the main thread will continue running and the application will be able to process events and callbacks from EXOS.

Indices and tables