CBD.realtime.threadingBackend module

class CBD.realtime.threadingBackend.Platform[source]

Bases: object

Identifies the platform to use in real-time simulation.

THREADING = 'python'

Use the default Python threading platform.

PYTHON = 'python'

Use the default Python threading platform.

TKINTER = 'tkinter'

Use the TkInter backend, to allow GUIs of the simulation.

TK = 'tkinter'

Use the TkInter backend, to allow GUIs of the simulation.

GAMELOOP = 'loop'

Use a gameloop backend, to keep the time yourself.

LOOP = 'loop'

Use a gameloop backend, to keep the time yourself.

GLA = 'loop_alt'

Use an alternative gameloop backend, to keep the time yourself.

class CBD.realtime.threadingBackend.ThreadingBackend(subsystem, args)[source]

Bases: object

Wrapper around the actual threading backend. It will also handle interrupts and the passing of them to the calling thread.

Parameters
  • subsystem (str) – String specifying the subsystem to use. Must be one of python, tkinter or loop (case-insensitive). The Platform class may be used to help identifying the subsystem.

  • args (list) – All additional arguments that should be passed to the subsystem’s constructor (must be a list). Only used for the tkinter subsystem.

is_alive()[source]

Checks that the main thread is alive.

Returns

code`True` when it is alive, otherwise False.

wait(time, func)[source]

A non-blocking call, which will call the func parameter after time seconds. It will use the provided backend to do this.

Parameters
  • time (float) – Time to wait in seconds.

  • func (callable) – The function to call after the time has passed.

step(time=0.0)[source]

Perform a step in the backend; only supported for the game loop backend.

Parameters

time (float) – The current simulation time. Only used if the alternative gameloop backend is used.

run_on_new_thread(func, args=())[source]

Runs a function on a new thread. :param func: The function to execute. :type func: callable :param args: The arguments for the function. :type args: iter