How to use the tasklib.background function in tasklib

To help you get started, we’ve selected a few tasklib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pupil-labs / pupil / pupil_src / shared_modules / tasklib / manager.py View on Github external
pass_shared_memory: If True, a shared memory object will be passed to the
                task (see tasklib.background.shared_memory.py). For this to work,
                your task needs to accept a keyword argument `shared_memory`.
            patches (collection of Patch): Patches that will be applied to your
                background process right after start. Use them if you need to fix
                something in the environment of the new process (see
                tasklib.background.patches.py).
                Per default, the IPC logging is patched.

        Returns:
            A new task with base class TaskInterface.

        """
        if patches is ...:
            patches = (IPCLoggingPatch(),)
        task = tasklib.background.create(
            name,
            routine_or_generator_function,
            pass_shared_memory,
            args,
            kwargs,
            patches,
        )
        self._recently_added_tasks.append(task)
        return task
github pupil-labs / pupil / pupil_src / shared_modules / gaze_producer / worker / map_gaze.py View on Github external
fake_gpool = _setup_fake_gpool(
        g_pool.capture.frame_size,
        g_pool.capture.intrinsics,
        calibration.mapping_method,
        g_pool.rec_dir,
    )

    args = (
        calibration.result,
        fake_gpool,
        pupil_pos_in_mapping_range,
        gaze_mapper.manual_correction_x,
        gaze_mapper.manual_correction_y,
    )
    name = "Create gaze mapper {}".format(gaze_mapper.name)
    return tasklib.background.create(
        name,
        _map_gaze,
        args=args,
        patches=[bg_patches.IPCLoggingPatch()],
        pass_shared_memory=True,
    )
github pupil-labs / pupil / pupil_src / shared_modules / gaze_producer / worker / create_calibration.py View on Github external
_create_ref_dict(ref)
        for ref in all_reference_locations
        if frame_start <= ref.frame_index <= frame_end
    ]

    fake_gpool = _setup_fake_gpool(
        g_pool.capture.frame_size,
        g_pool.capture.intrinsics,
        calibration.mapping_method,
        g_pool.rec_dir,
        calibration.minimum_confidence,
    )

    args = (fake_gpool, ref_dicts_in_calib_range, pupil_pos_in_calib_range)
    name = "Create calibration {}".format(calibration.name)
    return tasklib.background.create(
        name, _create_calibration, args=args, patches=[bg_patches.IPCLoggingPatch()]
    )
github pupil-labs / pupil / pupil_src / shared_modules / gaze_producer / worker / validate_gaze.py View on Github external
def create_bg_task(gaze_mapper, reference_location_storage):
    assert file_source, "You forgot to set capture by the plugin"
    refs_in_validation_range = reference_location_storage.get_in_range(
        gaze_mapper.validation_index_range
    )
    return tasklib.background.create(
        "validate gaze mapper '{}'".format(gaze_mapper.name),
        validate,
        args=(
            gaze_mapper,
            refs_in_validation_range,
            file_source.intrinsics,
            file_source.frame_size,
        ),