Skip to content

[hmr] async_derived weird semantics #473

Open

Description

@CNSeniorious000

For now, AsyncDerived.__call__ will returns a value which may be stale already.

async def _call_async(self):
await self._sync_dirty_deps()
try:
if self.dirty:
if self._call_task is not None:
await self._call_task
else:
task = self._call_task = self.start(self.recompute)
await task
return self._value
finally:
self._call_task = None
def __call__(self):
self.track()
return self.start(self._call_async)

If you want to ensure a fresh one, you have to do this:

async def _(d: AsyncDerived):

    while d.dirty:
        result = await self._run()
    return result

The question is, Should we simplify this, by

  1. provide an option in AsyncDerived to ensure this behavior in its __call__?
  2. provide an keyword argument in AsyncDerived.__call__ to ensure this behavior?

And, what about __sync_dirty_deps?

I personally tend to the first one.

Activity

  1. linear commented on Oct 15, 2025

    @linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions