def _set_timeout(func, timeout, repeat, *args, **kwargs):
    timeout_id = set_timeout._top_timeout_id
    if timeout_id > 100000:
        set_timeout._top_timeout_id = 0
    else:
        set_timeout._top_timeout_id += 1

    try:
        from . import api
    except __HOLE__:
        import api

    @api.send_errors
    def timeout_func():
        timeout_ids.discard(timeout_id)
        if timeout_id in cancelled_timeouts:
            cancelled_timeouts.remove(timeout_id)
            return

        func(*args, **kwargs)

        if repeat:
            editor.set_timeout(timeout_func, timeout)
            timeout_ids.add(timeout_id)

    editor.set_timeout(timeout_func, timeout)
    timeout_ids.add(timeout_id)
    return timeout_id
dataset/ETHPy150Open Floobits/floobits-sublime/floo/common/utils.py/_set_timeout