clockblocks.utilities

Utility functions, including versions of wait() and fork() that implicitly make use of the active clock on the current thread.

Functions

current_clock()

Get the Clock active on the current thread (or None if none is active)

fork(process_function[, args, kwargs, name, ...])

Spawns a parallel process running on a child clock of the currently active clock.

fork_unsynchronized(process_function[, ...])

Spawns a parallel process, but as an asynchronous thread, not on a child clock.

sleep_precisely(secs[, interruption_event])

High-precision sleep for the given number of seconds.

sleep_precisely_until(stop_time[, ...])

High-precision sleep until stop_time.

snap_float_to_nice_decimal(x[, ...])

If x is near to a nice decimal, this rounds it.

wait(dt[, units])

Calls wait() on the clock that is currently active on the thread.

wait_for_children_to_finish()

Calls wait_for_children_to_finish() on the clock that is currently active on the thread; generally, this is called when there are child clocks running and we want to keep the main script alive while the action takes place on the child clocks.

wait_forever()

Calls wait_forever() on the clock that is currently active on the thread; generally, this is called when there are child clocks running and we want to keep the main script alive while the action takes place on the child clocks.