Module: base

Classes in the base module are only accessible from Python applications.

class base.Application(run=True)

This is the main application object in the server. There can only be once instance of this object. The default constructor returns the instance of this object.

registerScheduledTask(fn, seconds=0, minutes=0, hours=0, days=0, runAtOnce=False, strictInterval=False, args=None, kwargs=None)

Register a semi regular scheduled task to run at a predefined interval. All calls will be made by the main thread.

fn:The function to be called.
seconds:The interval in seconds. Optional.
minutes:The interval in minutes. Optional.
hours:The interval in hours. Optional.
days:The interval in days. Optional.
runAtOnce:If the function should be called right away or wait one interval?
strictInterval:Set this to True if the interval should be strict. That means if the interval is set to 60 seconds and it was run ater 65 seconds the next run will be in 55 seconds.
args:Any args to be supplied to the function. Supplied as *args.
kwargs:Any keyworded args to be supplied to the function. Supplied as **kwargs.

Note

The interval in which this task is run is not exact and can be delayed one minute depending on the server load.

Note

Calls to this method are threadsafe.

isMainThread()

Returns True if the caller is running in the main thread

queue(fn, *args, **kwargs)

Queue a function to be executed later. All tasks in this queue will be run by the main thread. This is a thread safe function and can safely be used to syncronize with the main thread

registerShutdown(fn)

Register shutdown method. The method fn will be called the the server shuts down. Use this to clean up resources on shutdown.

static signal(msg, *args, **kwargs)

Send a global signal to registered slots. It is not recommended to call this method directly but instead use the signal decorator

class base.mainthread(f)
@mainthread

This decorator forces a method to be run in the main thread regardless of which thread calls the method.

class base.ISignalObserver

Bases: base.Plugin.IInterface

Implement this IInterface to recieve signals using the decorator @slot()

static SignalManager.slot(message='')
@slot

This is a decorator for receiveing signals. The class must implement ISignalObserver

Args:
message:This is the signal name to receive