# Stubs for tornado.gen (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any
from collections import namedtuple

singledispatch = ... # type: Any

class KeyReuseError(Exception): ...
class UnknownKeyError(Exception): ...
class LeakedCallbackError(Exception): ...
class BadYieldError(Exception): ...
class ReturnValueIgnoredError(Exception): ...
class TimeoutError(Exception): ...

def engine(func): ...
def coroutine(func, replace_callback=...): ...

class Return(Exception):
    value = ... # type: Any
    def __init__(self, value=...) -> None: ...

class WaitIterator:
    current_index = ... # type: Any
    def __init__(self, *args, **kwargs) -> None: ...
    def done(self): ...
    def next(self): ...

class YieldPoint:
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

class Callback(YieldPoint):
    key = ... # type: Any
    def __init__(self, key) -> None: ...
    runner = ... # type: Any
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

class Wait(YieldPoint):
    key = ... # type: Any
    def __init__(self, key) -> None: ...
    runner = ... # type: Any
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

class WaitAll(YieldPoint):
    keys = ... # type: Any
    def __init__(self, keys) -> None: ...
    runner = ... # type: Any
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

def Task(func, *args, **kwargs): ...

class YieldFuture(YieldPoint):
    future = ... # type: Any
    io_loop = ... # type: Any
    def __init__(self, future, io_loop=...) -> None: ...
    runner = ... # type: Any
    key = ... # type: Any
    result_fn = ... # type: Any
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

class Multi(YieldPoint):
    keys = ... # type: Any
    children = ... # type: Any
    unfinished_children = ... # type: Any
    quiet_exceptions = ... # type: Any
    def __init__(self, children, quiet_exceptions=...) -> None: ...
    def start(self, runner): ...
    def is_ready(self): ...
    def get_result(self): ...

def multi_future(children, quiet_exceptions=...): ...
def maybe_future(x): ...
def with_timeout(timeout, future, io_loop=..., quiet_exceptions=...): ...
def sleep(duration): ...

moment = ... # type: Any

class Runner:
    gen = ... # type: Any
    result_future = ... # type: Any
    future = ... # type: Any
    yield_point = ... # type: Any
    pending_callbacks = ... # type: Any
    results = ... # type: Any
    running = ... # type: Any
    finished = ... # type: Any
    had_exception = ... # type: Any
    io_loop = ... # type: Any
    stack_context_deactivate = ... # type: Any
    def __init__(self, gen, result_future, first_yielded) -> None: ...
    def register_callback(self, key): ...
    def is_ready(self, key): ...
    def set_result(self, key, result): ...
    def pop_result(self, key): ...
    def run(self): ...
    def handle_yield(self, yielded): ...
    def result_callback(self, key): ...
    def handle_exception(self, typ, value, tb): ...

Arguments = namedtuple('Arguments', ['args', 'kwargs'])

def convert_yielded(yielded): ...
