Clone wiki

pymoult / Pymoult manual

The Pymoult API

This page gives general directions to the Pymoult API, to get more
details about the functions and classes the pydoc can be build from
the sources.

DSU Threads

The DSU_Thread class from the pymoult.threads module enables some
DSU features while providing the features of regular threads.

  1. Thread reboot

    If a RebootException is raised inside a DSU Thread, the thread
    will stop its execution and restart again. The method to be run
    can be changed before rebooting (by changing the function held by
    the main method of the thread).

  2. Continuation support

    When a DSU_Thread starts, it generates a continuation that is
    put to sleep immediately. The switch method can be used to
    switch to that continuation. Switching to the sleeping
    continuation will cause the sleeping_continuation_function
    method of the thread to be called if it has been defined before
    returning to the thread main execution.

  3. Active and Passive Updates

    When using static alterability detection, the update can be donc
    by the thread (active update) or by a manager (passive
    ). When initiating the DSU_Thread, a active parameter
    can be set to True to precise that when reaching a
    staticUpdatePoint (from pymoult.lowlevel.alterability), the
    thread should run its active_update_function. If the active
    parameter is False (it is by default), when reaching a
    staticUpdatePoint and if wait_static_points (from
    pymoult.lowlevel.alterability) has been called, the thread will
    suspend itself and notify that it has reached an update point.

Using DSU_Thread is similar to regular threads from the threading
module, except the method to be run by the thread has to be named

The pymoult.threads module provides other utility functions such as

  • start_active_update starts an update within the thread (see the DSU page for the mechanism description)

  • set_active_update_function sets the update function for next active update (see the DSU page for the mechanism description)

  • get_thread_by_name returns the thread with the name given as argument

  • set_thread_trace takes a thread and a trace as arguments and sets
    the given trace for the given thread, then triggers it immediately.

High level API

The high level API of Pymoult contains three types of class. The
Listener class opens a socket for suppliying future updates. It has
to be started in the application. The Manager classes uses the DSU
mechanisms from the low level to watch the application and apply
modifications to it. The Update classes configure the Manager
classes by precising the targets of the update.

Low Level API

The low level API provides a set of functions and classes implementing
basic DSU mechanisms. They are spread among different modules,
depending on the issue they address. Each low level function provided by these modules are to be used as parts of Update classes. The functions must be called by the methods of these Update classes.