GitHub

API reference for Entry.

One pending request inside a batch: the request, the services of the fiber that made it, and the way to complete it.

Resolvers complete each entry once; later completions are ignored. uninterruptible keeps the entry in its batch when its caller is interrupted (with_cache sets it on a request others wait for).

Attributes

AttributeTypeDescription
uninterruptible= uninterruptible
requestQ_co
contextContext

The services of the fiber that made the request.

Functions

__init__

__init__(request, *, context, complete_unsafe, uninterruptible=False) -> None
ParameterTypeDescription
requestQ_co
contextContext
complete_unsafeCallable[[Exit[Any, Any]], None]
uninterruptiblebool = False
def __init__(
    self,
    request: Q_co,
    *,
    context: Context,
    complete_unsafe: Callable[[Exit[Any, Any]], None],
    uninterruptible: bool = False,
) -> None:
    self._request = request
    self._context = context
    self._complete = complete_unsafe
    self.uninterruptible = uninterruptible

complete_unsafe

complete_unsafe(ex) -> None

Complete the request now with ex.

ParameterTypeDescription
exExit[A, E]
def complete_unsafe[A, E](self: Entry[Request[A, E, Any]], ex: Exit[A, E], /) -> None:
    """Complete the request now with ``ex``."""
    self._complete(ex)

complete

complete(ex) -> Effect[None]

The effect that completes the request with ex.

ParameterTypeDescription
exExit[A, E]

Returns Effect[None]

def complete[A, E](self: Entry[Request[A, E, Any]], ex: Exit[A, E], /) -> Effect[None]:
    """The effect that completes the request with ``ex``."""
    return _Sync(lambda: self._complete(ex))

complete_effect

complete_effect(eff) -> Effect[None, Never, R]

Run eff and complete the request with its value or typed error. Defects and interruptions are not caught.

ParameterTypeDescription
effEffect[A, E, R]

Returns Effect[None, Never, R]

def complete_effect[A, E, R](
    self: Entry[Request[A, E, Any]], eff: Effect[A, E, R], /
) -> Effect[None, Never, R]:
    """Run ``eff`` and complete the request with its value or typed
    error. Defects and interruptions are not caught."""
    require_effect(eff, "eff")
    complete = self._complete

    def done(ex: Exit[Any, Any]) -> Effect[None]:
        complete(ex)
        return _VOID

    return eff.match_effect(
        on_failure=lambda e: done(exit_fail(e)), on_success=lambda a: done(Success(a))
    )

succeed

succeed(value) -> Effect[None]
ParameterTypeDescription
valueA

Returns Effect[None]

def succeed[A](self: Entry[Request[A, Any, Any]], value: A, /) -> Effect[None]:
    return _Sync(lambda: self._complete(Success(value)))

fail

fail(error) -> Effect[None]
ParameterTypeDescription
errorE

Returns Effect[None]

def fail[E](self: Entry[Request[Any, E, Any]], error: E, /) -> Effect[None]:
    return _Sync(lambda: self._complete(exit_fail(error)))

fail_cause

fail_cause(cause) -> Effect[None]
ParameterTypeDescription
causeCause[E]

Returns Effect[None]

def fail_cause[E](self: Entry[Request[Any, E, Any]], cause: Cause[E], /) -> Effect[None]:
    return _Sync(lambda: self._complete(Failure(cause)))