-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
For now, AsyncDerived.__call__ will returns a value which may be stale already.
pyth-on-line/packages/hmr/reactivity/async_primitives.py
Lines 126 to 143 in ec2523f
| 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 resultThe question is, Should we simplify this, by
- provide an option in
AsyncDerivedto ensure this behavior in its__call__? - provide an keyword argument in
AsyncDerived.__call__to ensure this behavior?
And, what about __sync_dirty_deps?
I personally tend to the first one.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request