system38340%python.module
fault.kernel

System abstractions and processors for managing a processing tree.

os
import

sys0
import

functools0
import

collections0
import

contextlib0
import

weakref0
import

traceback0
import

itertools0
import

signal0
import

operator0
import

heapq0
import

sleep0
import

tools0
import

weak0
import

kernel0
import

network0
import

io0
import

process0
import

thread0
import

memory0
import

execution0
import

time0
import

core0
import

flows0
import

text0
import

__process_index__0
data

__process_index__ = dict()

Matrix0
class

Collection of fault.system.io.Array instances connecting transfers to KChannel instances.

MatrixArray0
import

Matrixchannels_per_array0
data

channels_per_array = 1024 * 16

MatrixDelta0
class

Transfer events snapshot delivered to I/O tasks.

MatrixDelta__slots__0
data

__slots__ = ()

MatrixDelta__str__0
method

__str__(self)

MatrixDelta__repr__0
method

__repr__(self)

MatrixDeltapayload0
property

Units sent.

MatrixDeltademand0
property

The acquire method of the channel if exhausted. None if not exhausted.

MatrixDeltaterminal0
property

Whether or not this is the last event from the Channel.

MatrixDeltaendpoint0
property

MatrixDeltaconstruct0
classmethod

construct(Class)

MatrixDeltasnapshot0
classmethod

snapshot(Class, channel)

Matrixio_collect653%
staticmethod

io_collect(transfers)

Process the array's transfer and construct a sequence of I/O events.

This is executed inside a thread managed by the matrix and cannot deliver the events to Transformers. synchronize_io_events is used to deliver the queue for processing in the main task queue.

Matrixio_deliver1534%
staticmethod

io_deliver(error, events)

Send the individual events originally prepared by io_collect to their associated KInput or KOutput flows.

Matrixio_delta40%
staticmethod

io_delta(array)

Inline I/O handler for schduler based transfers.

Matrixio_loop292%
staticmethod

io_loop()

Matrix__init__0
method

__init__(self, errors, synchronize, execute)

Matrix_alloc0
method

_alloc(self)

Matrix_get0
method

_get(self)

Matrixvoid175%
method

void(self)

Violently destroy all channels and Arrays in the Matrix.

All arrays allocated by the Matrix will be terminated.

WARNING

This method should only be ran after forking and inside the child process.

Matrixforce0
method

force(self)

Execute the Array.force method on the set designated of Array instances designated by id.

Matrixterminate0
method

terminate(self)

Terminate all arrays managed by the matrix.

Matrixacquire0
method

acquire(self, channels)

Acquire a set of channels accounting for volume limits.

KChannel0
class

Channel moving data in or out of the operating system's kernel.

KChannelk_status
data

k_status = None

KChannel__init__0
method

__init__(self)

KChannelactuate0
method

actuate(self)

KChannelk_meta30%
method

k_meta(self)

KChannel__repr__110%
method

__repr__(self)

KChannelstructure110%
method

structure(self)

KChannelk_transition10%
method

k_transition(self)

KChannelk_kill50%
method

k_kill(self)

Called by the controlling Flow, acquire status information and unlink the channel.

KChannelinterrupt30%
method

interrupt(self)

KChannelf_terminated30%
method

f_terminated(self)

KChannelf_transfer10%
method

f_transfer(self, event)

KChannelk_transferring0
property

The length of the buffer being transferred into or out of the kernel.

None if no transfer is currently taking place.

KAllocate0
class

Flow that continually allocates memory for a channel transferring data into the process.

KAllocatef_clear20%
method

f_clear(self, obstruction)

KAllocatek_transition0
method

k_transition(self)

Transition in the next buffer provided that the Flow was not obstructed.

KAllocatef_transfer30%
method

f_transfer(self, event)

Normally ignored, but will induce a transition if no transfer is occurring.

KAccept0
class

Manage the event connection to a listening socket and process read events by accepting and transmitting the socket file descriptors.

KAcceptAllocate0
data

Allocate = kernel.Ports.allocate

KAccept__init__30%
method

__init__(self, kport)

KAcceptactuate10%
method

actuate(self)

KAcceptf_transfer30%
method

f_transfer(self, event)

KAcceptinterrupt30%
method

interrupt(self)

KAcceptf_terminate20%
method

f_terminate(self)

KInput0
class

Receive octets from the system I/O channel.

KLimit0
class

Receive octets from the system I/O channel with limited memory allocations. Primarily used to read portions of a file.

KLimitk_limit
data

k_limit = None

KLimitk_set_limit80%
method

k_set_limit(self, limit)

KLimitk_transition50%
method

k_transition(self)

Transition in the next buffer provided that the Flow was not obstructed.

KOutput0
class

Flow that transfers emitted events to be transferred into the kernel.

The queue is limited to a certain number of items rather than a metadata constraint; for instance, the sum of the length of the buffer entries. This allows the connected Flows to dynamically choose the buffer size by adjusting the size of the events.

KOutputko_limit
data

ko_limit = 16
	@property

KOutputko_overflow20%
property

Queue entries exceeds limit.

KOutputf_empty40%
property

KOutput__init__0
method

__init__(self, channel)

KOutputk_transition442%
method

k_transition(self)

KOutputf_transfer266%
method

f_transfer(self, event)

Enqueue a sequence of transfers to be processed by the Transit.

KOutputf_terminate50%
method

f_terminate(self)

Context0
class

System Transaction Context implementation providing Abstract Processors with access to the local system.

Contextxact_exit90%
method

xact_exit(self, xact)

Contextxact_void40%
method

xact_void(self, final)

Final (executable) transaction exited; system process context complete.

Contextinterrupt30%
method

interrupt(self)

Contextsigterm20%
method

sigterm(self, link)

Contextterminate30%
method

terminate(self)

Contextprocess0
property

Contextkdispatch30%
method

kdispatch(self, event, task)

Contextkcancel10%
method

kcancel(self, event)

Context__init__0
method

__init__(self, process)

Contextuptime0
data

uptime = staticmethod(time.elapsed)

Contexttime0
data

time = staticmethod(time.utc)

Context_defer_reference
data

_defer_reference = None

Context_defer_execute100%
method

_defer_execute(self)

Execute all tasks whose wait period has elapsed according to the system's clock.

Contextdefer90%
method

defer(self, measure, *processors)

Defer the execution of the occur methods on the given processors by the given measure.

Contextcancel10%
method

cancel(self, processor)

Context_defer_update40%
method

_defer_update(self, snapshot)

Context_defer_period30%
method

_defer_period(self, current)

Context_defer_put325%
method
int

_defer_put(self, current, measure, processors)

Context_defer_get130%
method

_defer_get(self, current)

Contextstructure40%
method

structure(self)

Contextactuate0
method

actuate(self)

Contextconnect_process_signal30%
method

connect_process_signal(self, xact_context, callback, signal)

Contextconnect_process_exit180%
method

connect_process_exit(self, xact_context, callback, *processes)

Contextallocate0
method

allocate(self, xactctx)

Launch an Executable for running application processors.

Contextreport30%
method

report(self, target)

Send an overview of the logical process state to the given target.

Context_recur40%
method

_recur(self, frequency, task)

Schedule the task for execution after the period of time measure elapses.

core.Scheduler instances will resubmit a task if there is a substantial delay remaining. When large duration defers are placed, the seconds unit are used and decidedly inexact, so resubmission is used with a finer grain.

Context_cancel20%
method

_cancel(self, task)

Cancel a scheduled task.

Contextinherit20%
method

inherit(self, context)

Inherit the exports from the given context.

Context_io_cycle20%
method

_io_cycle(self)

Signal the Process that I/O occurred for this context.

Context_io_attach30%
method

_io_attach(self, *channels)

Context_io_flush50%
method

_io_flush(self)

Contextexecute20%
method

execute(self, controller, function, *parameters)

Execute the given function in a thread associated with the specified controller.

Contextenviron40%
method

environ(self, identifier)

Access the environment from the perspective of the context. Context overrides may hide process environment variables.

Contextoverride50%
method

override(self, identifier, value)

Override an environment variable for the execution context.

Child processes spawned relative to the context will inherit the overrides.

Contextbindings30%
method

bindings(self, *allocs)

Returns a sequence of file descriptors that can later be acquired by a Matrix.

Contextconnect30%
method

connect(self, endpoint)

Given an endpoint and a transport stack, return the series used to manage the connection's I/O.

ContextconnectParameters

self

Undocumented.

endpoint

The library.Endpoint instance describing the target of the connection.

Contextallocate_transport30%
method

allocate_transport(self, fd)

Given a file descriptor and a transport stack, return the series used to manage the connection's I/O.

Contextallocate_transportParameters

self

Undocumented.

fd

Socket file descriptor.

Contextread_file30%
method

read_file(self, path)

Construct a channel for reading an entire file from the filesystem. The returned channel terminates when EOF occurs; often, read_file_range is preferrable to avoid status inconsistencies.

Contextwrite_file325%
method

write_file(self, path)

Construct a channel for writing to the file identified by path.

Contextread_file_range100%
method

read_file_range(self, path, start, stop)

Construct a channel to read a specific range of a file.

Contextappend_file30%
method

append_file(self, path)

Open a set of files for appending through a library.KernelPort.

Contextupdate_file50%
method

update_file(self, path, offset, size)

Allocate a channel for overwriting data at the given offset of the designated file.

Contextlisten40%
method

listen(self, interfaces)

On POSIX systems, this performs bind and listen system calls for receiving socket connections.

Returns a generator producing (interface, KAccept) pairs.

Contextaccept_sockets20%
method

accept_sockets(self, kp)

Construct a Channel processor that emite accepted listening sockets.

Contextconnect_output20%
method

connect_output(self, fd)

Allocate channel instances for the given sequence of file descriptors.

Contextconnect_input20%
method

connect_input(self, fd)

Allocate channel instances for the given sequence of file descriptors.

Contextdaemon156%
method
tuple[int, int]

daemon(self, invocation)

Execute the fault.system.execution.KInvocation instance with stdin and stdout closed.

Returns the process identifier and standard error's file descriptor as a tuple.

Contextdaemon_stderr110%
method

daemon_stderr(self, stderr, invocation)

Execute the fault.system.execution.KInvocation instance with stdin and stdout closed. The stderr parameter will be passed in as the standard error file descriptor, and then closed before returning.

Returns a Subprocess instance containing a single Process-Id.

Used to launch a daemon with a specific standard error for monitoring purposes.

Contextsystem_execute20%
method

system_execute(self, invocation)

Execute the fault.system.execution.KInvocation inheriting standard input, output, and error.

This is used almost exclusively by shell-type processes where the calling process suspends TTY I/O until the child exits.

Contextstream_shared_segments325%
method

stream_shared_segments(self, path, range, *_)

Construct a new Flow with an initial Iterate Transformer flowing shared memory segments from the memory mapped file.

Returns a pair, the new Flow and a callable that causes the Flow to begin transferring memory segments.

Contextstream_shared_segmentsParameters

self

Undocumented.

path

Local filesystem path to read from.

range

A triple, (start, stop, size), or None if the entire file should be used. Where size is the size of the memory slices to emit.

_

Undocumented.

Segments

Undocumented.

Contextcoprocess20%
method

coprocess(self, identifier, exit, invocation, application)

Dispatch a local parallel process.

Fabric0
class

Thread manager for processes; thread pool with capacity to manage dedicated threads.

Fabric__init__0
method

__init__(self, process)

Fabricvoid20%
method

void(self)

Normally used after a process fork in the child.

Fabricexecute20%
method

execute(self, controller, callable, *args)

Create a dedicated thread and execute the given callable within it.

Fabriccritical20%
method

critical(self, controller, context, callable, *args)

Create a dedicated thread that is identified as a critical resource where exceptions trigger fault.system.process.Critical exceptions in the main thread.

The additional context parameter is an arbitrary object describing the resource; often the object whose method is considered critical.

Fabricspawn30%
method

spawn(self, controller, callable, args)

Add a thread to the fabric. This expands the "parallel" capacity of a Process.

Fabricthread118%
method

thread(self, *parameters)

Manage the execution of a thread.

Fabricexecuting20%
method

executing(self, tid)

Whether or not the given thread [identifier] is executing in this Fabric instance.

Process0
class

The representation of the system process that is running. Usually referred to as process by Context and other classes.

Usually only one Process is active per-process, but it can be reasonable to launch multiple in order to perform operations that would otherwise expect its own space.

ProcessProperties

fabric

The Fabric instance managing the threads controlled by the process.

Processcurrent50%
staticmethod

current()

Resolve the current logical process based on the thread's identifier. None is returned if the thread was not created by a Process.

Processtransaction0
method
core.Transaction

transaction(self)

Return the primary library.Unit instance associated with the process.

Processkernel0
property

Processactuate_root_transaction0
method

actuate_root_transaction(self)

Processlog30%
method

log(self, data)

Append only access to a critical process log. Usually points to sys.stderr and primarily used for process related issues.

Processboot0
method

boot(self, *tasks)

Boot the Process with the given tasks enqueued in the Task queue.

Only used inside the main thread for the initialization of the controlling processor.

Processterminate60%
method

terminate(self)

Terminate the process closing the task queue and running the invocation's exit.

Process__init__0
method

__init__(self, exit, identifier)

Initialize the Process instance using the designated identifier. The identifier is essentially arbitrary, but must be hashable as it's used to distinguish one Representation from another. However, usually there is only one process, so "root" or "main" is often used.

Normally, execute is used to manage the construction of the Process instance.

Process_setup0
method

_setup(self)

Process_init_exit0
method

_init_exit(self)

Process_init_io0
method

_init_io(self)

Processvoid40%
method

void(self)

Tear down the existing logical process state. Usually used internally after a physical process fork.

Process__repr__10%
method

__repr__(self)

Processerror50%
method

error()

Handler for untrapped exceptions.

Processtitled_error10%
method

titled_error(self, title)

main_thread_task_queue
data

main_thread_task_queue = None

main_thread_interrupt
data

main_thread_interrupt = None

main_thread_exit_status
data

main_thread_exit_status = 255

reset40%
function

reset()

Reset the process global state of system.

exit50%
function

exit()

Default exit callback used to interrupt main thead task queue.

Sets the module attribute main_thread_exit_status to the given status and closes the main task queue.

spawn0
function
Process

spawn(exit, identifier, executables)

Construct a Process using the given executables. The identifier is usually 'root' for the primary logical process.

dispatch0
function
Process

dispatch(invocation, application)

Dispatch an application context instance within a new logical process.

Construct a Process and fault.kernel.core.Executable for executing the application context. The Process created by the inner spawn is returned.

reports30%
function

reports(link)

set_root_process140%
function

set_root_process(process)

Connect the system process termination signal to root transaction terminate.

default_error_trap60%
function

default_error_trap(link, call, error)

control0
function

control(**kw)

Control the main thread providing a low precision timer for deferred tasks. Called by an application's main entry point after booting the Process created by spawn.

protect753%
function

protect(error_control)