import random


def determine_jitter(count, node_settings):
    """Return a pseudo-random number of seconds to delay a run."""
    count *= node_settings.jitter_load_factor
    min_count = node_settings.jitter_min_load
    max_jitter = max(0.0, count - min_count)
    max_jitter = min(node_settings.jitter_max_delay, max_jitter)
    return random.random() * float(max_jitter)