Wiki
Clone wikipymoult / 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.
-
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). -
Continuation support
When a
DSU_Thread
starts, it generates a continuation that is put to sleep immediately. Theswitch
method can be used to switch to that continuation. Switching to the sleeping continuation will cause thesleeping_continuation_function
method of the thread to be called if it has been defined before returning to the thread main execution. -
Active and Passive Updates
When using static alterability detection, the update can be donc by the thread (active update) or by a manager (passive update). When initiating the
DSU_Thread
, aactive
parameter can be set toTrue
to precise that when reaching astaticUpdatePoint
(frompymoult.lowlevel.alterability
), the thread should run itsactive_update_function
. If theactive
parameter isFalse
(it is by default), when reaching astaticUpdatePoint
and ifwait_static_points
(frompymoult.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
main
.
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
.
Updated