コード例 #1
0
    spawn_n = greenthread.spawn_n
    spawn_after = greenthread.spawn_after
    kill = greenthread.kill

    import_patched = patcher.import_patched
    monkey_patch = patcher.monkey_patch

    Queue = queue.Queue

    Semaphore = semaphore.Semaphore
    CappedSemaphore = semaphore.CappedSemaphore
    BoundedSemaphore = semaphore.BoundedSemaphore

    Timeout = timeout.Timeout
    with_timeout = timeout.with_timeout
    wrap_is_timeout = timeout.wrap_is_timeout
    is_timeout = timeout.is_timeout

    getcurrent = greenlet.greenlet.getcurrent

    # deprecated
    TimeoutError, exc_after, call_after_global = (support.wrap_deprecated(
        old, new)(fun) for old, new, fun in (
            ('TimeoutError', 'Timeout', Timeout),
            ('exc_after', 'greenthread.exc_after', greenthread.exc_after),
            ('call_after_global', 'greenthread.call_after_global',
             greenthread.call_after_global),
        ))

del os
コード例 #2
0
    spawn = greenthread.spawn
    spawn_n = greenthread.spawn_n
    spawn_after = greenthread.spawn_after
    kill = greenthread.kill

    import_patched = patcher.import_patched
    monkey_patch = patcher.monkey_patch

    Queue = queue.Queue

    Semaphore = semaphore.Semaphore
    CappedSemaphore = semaphore.CappedSemaphore
    BoundedSemaphore = semaphore.BoundedSemaphore

    Timeout = timeout.Timeout
    with_timeout = timeout.with_timeout
    wrap_is_timeout = timeout.wrap_is_timeout
    is_timeout = timeout.is_timeout

    getcurrent = greenlet.greenlet.getcurrent

    # deprecated
    TimeoutError, exc_after, call_after_global = (
        support.wrap_deprecated(old, new)(fun) for old, new, fun in (
            ('TimeoutError', 'Timeout', Timeout),
            ('exc_after', 'greenthread.exc_after', greenthread.exc_after),
            ('call_after_global', 'greenthread.call_after_global', greenthread.call_after_global),
        ))

del os
コード例 #3
0
ファイル: __init__.py プロジェクト: 2216288075/meiduo_project
    spawn = greenthread.spawn
    spawn_n = greenthread.spawn_n
    spawn_after = greenthread.spawn_after
    kill = greenthread.kill

    import_patched = patcher.import_patched
    monkey_patch = patcher.monkey_patch

    Queue = queue.Queue

    Semaphore = semaphore.Semaphore
    CappedSemaphore = semaphore.CappedSemaphore
    BoundedSemaphore = semaphore.BoundedSemaphore

    Timeout = timeout.Timeout
    with_timeout = timeout.with_timeout
    wrap_is_timeout = timeout.wrap_is_timeout
    is_timeout = timeout.is_timeout

    getcurrent = greenlet.greenlet.getcurrent

    # deprecated
    TimeoutError, exc_after, call_after_global = (
        support.wrap_deprecated(old, new)(fun) for old, new, fun in (
            ('TimeoutError', 'Timeout', Timeout),
            ('exc_after', 'greenthread.exc_after', greenthread.exc_after),
            ('call_after_global', 'greenthread.call_after_global', greenthread.call_after_global),
        ))

del os
コード例 #4
0
ファイル: greenthread.py プロジェクト: 827275701/other

def exc_after(seconds, *throw_args):
    warnings.warn(
        "Instead of exc_after, which is deprecated, use "
        "Timeout(seconds, exception)",
        DeprecationWarning,
        stacklevel=2)
    if seconds is None:  # dummy argument, do nothing
        return timer.Timer(seconds, lambda: None)
    hub = hubs.get_hub()
    return hub.schedule_call_local(seconds, getcurrent().throw, *throw_args)


# deprecate, remove
TimeoutError, with_timeout = (support.wrap_deprecated(old, new)(fun)
                              for old, new, fun in (
                                  ('greenthread.TimeoutError', 'Timeout',
                                   timeout.Timeout),
                                  ('greenthread.with_timeout', 'with_timeout',
                                   timeout.with_timeout),
                              ))


def _spawn_n(seconds, func, args, kwargs):
    hub = hubs.get_hub()
    g = greenlet.greenlet(func, parent=hub.greenlet)
    t = hub.schedule_call_global(seconds, g.switch, *args, **kwargs)
    return t, g