Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/async_kernel/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Future(Awaitable[T]):
"""

__slots__ = [
"__weakref__",
"_anyio_event_done",
"_cancel_scope",
"_cancelled",
Expand All @@ -64,6 +65,8 @@ class Future(Awaitable[T]):
"thread",
]
_result: T
thread: threading.Thread
"The thread in which the result is targeted to run."

def __init__(self, thread: threading.Thread | None = None) -> None:
self._event_done = threading.Event()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import threading
import time
import weakref
from contextvars import ContextVar
from random import random
from typing import Literal, cast
Expand Down Expand Up @@ -30,6 +31,10 @@ def transport(request):

@pytest.mark.anyio
class TestFuture:
def test_weakref(self):
f = Future()
assert weakref.ref(f)() is f

async def test_set_and_wait_result(self):
fut = Future[int]()
assert inspect.isawaitable(fut)
Expand Down
Loading