Module lyntin.engine
This holds the engine which both contains most of the other
objects that do work in Lyntin as well as encapsulates the event queue,
event handling methods, and some of the other singleton managers such as
the HelpManager and the CommandManager.
Engine also holds hooks to the various event types. Events will call
all appropriate hooks allowing you to add functionality via the modules
interface without changing the Lyntin internals.
The engine also holds a list of registered threads. This helps in
diagnostics. Use the methods in exported to handle spinning off
threads.
The Engine class is a singleton and the reference to it is stored in
"engine.Engine.instance". However, you should use the exported
module to access the engine using the "get_engine()"
function.
startup_hook:
The startup hook is called after Lyntin has bootstrapped itself
enough to allow everything to initialize itself.
Arg mapping: {}
shutdown_hook:
When Lyntin is shutting down, this hook is called. It's possible
Lyntin might be in a state of disarray at this point, so it's not
clear what is and what is not available.
Arg mapping: {}
timer_hook:
The timer hook spams all registered functions every second. This
is how the scheduler works.
Arg mapping: { "tick": int }
tick - the current tick (starts at 0)
from_user_hook:
All input typed in by the user (as well as other things that
eventually go through the handleUserData method) get passed
through this hook (unless it's specified as internal). All
registered functions get to see the raw user data this way.
Arg mapping: {"data": string}
data - the user data passed into handleUserData
to_user_hook:
This hook is for data to be displayed to the user. The UI listens
on this hook as do logger functions.
NOTE: Functions registered with this hook should NEVER call
exported.write* functions. That will result in an infinite loop and
then Lyntin will either hang or die. If you want to spit out output
use an OutputEvent.
Arg mapping: { "message": string }
message - The message to be displayed. This can be either a string
of a ui.base.Message object.
error_occurred_hook:
Every time an event kicks up an unhandled error, we add one to
our error count and also spam this hook with the current
number of errors.
Arg mapping: { "count": int }
count - the current number of errors
too_many_errors_hook:
When we hit the maximum number of errors, this hook gets spammed and
then Lyntin shuts down.
Arg mapping: {}
session_change_hook:
This hook gets spammed whenever the current session changes,
after changing.
Arg mapping: { "new": session.Session, "previous": session.Session }
new - the session that is being changed to
previous - the session that was previously the current session
| Classes |
Engine |
This is the engine class. |
| Function Summary |
| |
main(defaultoptions)
This parses the command line arguments and makes sure they're all
valid, instantiates a ui, does some setup, spins off an engine thread,
and goes into the ui's mainloop. |
| |
shutdown()
This gets called by the Python interpreter atexit. |
main(defaultoptions={})
This parses the command line arguments and makes sure they're all
valid, instantiates a ui, does some setup, spins off an engine thread,
and goes into the ui's mainloop.
-
- Parameters:
defaultoptions -
the boot options to use. we update the config.options dict
with these options--this is the easiest way to override the ui,
moduledir, datadir, et al from a Lyntin run script.
(type=dict)
|
shutdown()
This gets called by the Python interpreter atexit. The reason we do
shutdown stuff here is we're more likely to catch things here than we
are to let everything cycle through the ShutdownEvent. This should
probably get fixed up at some point in the future.
Do not call this elsewhere.
-
|