pupil_recording_interface.StreamManager

class pupil_recording_interface.StreamManager(configs, folder=None, policy='new_folder', duration=None, update_interval=0.01, status_timeout=1.0, max_queue_size=20, app_info=None)

Bases: object

Manager for multiple streams.

__init__(configs, folder=None, policy='new_folder', duration=None, update_interval=0.01, status_timeout=1.0, max_queue_size=20, app_info=None)

Constructor.

Parameters
  • configs (iterable of StreamConfig) – An iterable of stream configurations.

  • folder (str, optional) – Path to the recording folder if any of the streams are being recorded.

  • policy (str, default 'new_folder') – Policy for recording folder creation. If ‘new_folder’, new sub-folders will be created with incremental numbering. If ‘here’, the data will be recorded to the specified folder but will throw an error when existing files would be overwritten. If ‘overwrite’, the data will be recorded to the specified folder and existing files will possibly be overwritten. If ‘read’, the folder is only read from, for example when using a ‘video_file’ device.

  • duration (float, optional) – If provided, the number of seconds after which the streams are stopped.

  • update_interval (float, default 0.01) – Time in seconds between status and notification updates. Higher values might lead to to delays in communicating with the processes and dropped messages while lower values might lead to increased CPU load of the main process. Set to None for maximum update rate. Will be dropped in a future version with an asynchronous implementation of the update mechanism.

  • status_timeout (float, default 1.0) – Maximum time in seconds to wait for status updates from a stream. After this time, the status of the stream will be reset to the default.

  • max_queue_size (int, default 20) – Maximum size of process status and notification queues. Higher values might lead to delays in communicating with the processes while lower values might lead to dropped messages.

  • app_info (dict) – When using pupil_recording_interface as the backend for a recording app, provide a dict with the "name" and "version" of your app such that the “recording_software_name” and “recording_software_version” fields in info.player.json will be set appropriately.

Methods

__init__(configs[, folder, policy, …])

Constructor.

await_status(stream, **kwargs)

Wait for a stream to report a certain status.

format_status(key[, format, nan_format, …])

Format status dictionary to string.

run()

Main loop (blocking).

save_info([final])

Save info.player.json file.

send_notification(notification[, streams])

Send a notification over the priority queues.

spin([block])

Main worker loop of the manager.

spin_generator()

Main worker loop of the manager, implemented as a generator.

start()

Start recording.

stop()

Stop streams.

Attributes

all_streams_running

run_duration

await_status(stream, **kwargs)

Wait for a stream to report a certain status.

format_status(key, format='{:.2f}', nan_format='no data', status_dict=None, max_cols=None, sleep=None)

Format status dictionary to string.

run()

Main loop (blocking).

save_info(final=True)

Save info.player.json file.

Parameters

final (bool, default True) – If False, assume that this method is called at the start of the recording and save placeholders for values that can still change.

send_notification(notification, streams=None)

Send a notification over the priority queues.

spin(block=True)

Main worker loop of the manager.

Parameters

block (bool, default True) – If True, this method will block until the manager is stopped, e.g. by a keyboard interrupt. Otherwise, the main loop is dispatched to a separate thread which is returned by this function.

Returns

thread – If block=True, the Thread instance that runs the loop.

Return type

threading.Thread

spin_generator()

Main worker loop of the manager, implemented as a generator.

Yields

status (dict) – A mapping from stream names to their current status.

start()

Start recording.

stop()

Stop streams.