# Path: asynq/decorators.py
# def asynq(self, *args, **kwargs):
#     if self.instance is None:
#         return self.decorator.asynq(*args, **kwargs)
#     else:
#         return self.decorator.asynq(self.instance, *args, **kwargs)
# 
# def async_proxy(pure=False, sync_fn=None):
#     if sync_fn is not None:
#         assert pure is False, "sync_fn=? cannot be used together with pure=True"
# 
#     def decorate(fn):
#         if pure:
#             return fn
#         if sync_fn is None:
#             return qcore.decorators.decorate(AsyncProxyDecorator)(fn)
#         else:
#             return qcore.decorators.decorate(AsyncAndSyncPairProxyDecorator, sync_fn)(
#                 fn
#             )
# 
#     return decorate
# 
# Path: asynq/futures.py
# class ConstFuture(FutureBase):
#     """Future wrapping the constant."""
# 
#     def __init__(self, value):
#         self._value = _none
#         self._error = None
#         self.on_computed = (
#             core_events.sinking_event_hook
#         )  # Simple performance optimization
#         self.set_value(value)
#         self._in_repr = False  # since we don't call super.__init__
# 
#     def __reduce__(self):
#         return (ConstFuture, (self._value,))


import qcore
import functools
from .decorators import asynq, async_proxy
from .futures import ConstFuture
            continue
        data.append(value)
    return data


@asynq()
def take_first(generator, n):
    """Returns the first n values in the generator."""
    ret = []
    for i, task in enumerate(generator):
        value = yield task
        if value is END_OF_GENERATOR:
            continue
        ret.append(value)
        if i == n - 1:
            break
    return ret


class _AsyncGenerator(object):
    def __init__(self, generator):
        self.generator = generator
        self.last_task = None
        self.is_stopped = False

    def __iter__(self):
        return self

    @async_proxy(pure=True)
    def next(self):

# Path: asynq/decorators.py
# def asynq(self, *args, **kwargs):
#     if self.instance is None:
#         return self.decorator.asynq(*args, **kwargs)
#     else:
#         return self.decorator.asynq(self.instance, *args, **kwargs)
# 
# def async_proxy(pure=False, sync_fn=None):
#     if sync_fn is not None:
#         assert pure is False, "sync_fn=? cannot be used together with pure=True"
# 
#     def decorate(fn):
#         if pure:
#             return fn
#         if sync_fn is None:
#             return qcore.decorators.decorate(AsyncProxyDecorator)(fn)
#         else:
#             return qcore.decorators.decorate(AsyncAndSyncPairProxyDecorator, sync_fn)(
#                 fn
#             )
# 
#     return decorate
# 
# Path: asynq/futures.py
# class ConstFuture(FutureBase):
#     """Future wrapping the constant."""
# 
#     def __init__(self, value):
#         self._value = _none
#         self._error = None
#         self.on_computed = (
#             core_events.sinking_event_hook
#         )  # Simple performance optimization
#         self.set_value(value)
#         self._in_repr = False  # since we don't call super.__init__
# 
#     def __reduce__(self):
#         return (ConstFuture, (self._value,))


# Path: asynq/generator.py
import qcore
import functools
from .decorators import asynq, async_proxy
from .futures import ConstFuture

            continue
        data.append(value)
    return data


@asynq()
def take_first(generator, n):
    """Returns the first n values in the generator."""
    ret = []
    for i, task in enumerate(generator):
        value = yield task
        if value is END_OF_GENERATOR:
            continue
        ret.append(value)
        if i == n - 1:
            break
    return ret


class _AsyncGenerator(object):
    def __init__(self, generator):
        self.generator = generator
        self.last_task = None
        self.is_stopped = False

    def __iter__(self):
        return self

    @async_proxy(pure=True)
    def next(self):

        return self.send.asynq(None)