Skip to content

[hmr] Cyclic Dependency Handling #269

Open

Description

@CNSeniorious000

This is a followup of #255.

with wait_for_tick():
Path("b.py").write_text("print('b')\n\nfrom a import one\n\ntwo = one + 2\n")
assert stdout.delta == "b\na\nc\n5\n" # b <- a <- c
with wait_for_tick():
Path("a.py").write_text("print('a')\n\none = 2\n\nfrom b import two\n\nthree = two + 2\n")
assert stdout.delta == "a\nb\na\nc\n6\n" # a <- b, b <- a <- c
"""
TODO This is not an optimal behavior. Here are 2 alternate solutions:
1. Maximize consistency:
Log the order of each `Derived` and replay every loop in its original order.
Always run `a` before `b` in the tests above.
2. Greedy memoization:
Always run the changed module first. Only run `a` when necessary.
But if `a.one` changes every time, we'll have to run `b` twice to keep consistency.
"""

Personally I prefer the first solution. And we may provide an option for user to opt-in the second solution.

Activity

  1. added this to the Refinements milestone on May 12, 2025
  2. linear commented on May 12, 2025

    @linear
  3. changed the title [-]Cyclic Dependency Handling[/-] [+][hmr] Cyclic Dependency Handling[/+] on May 22, 2025
  4. added a commit that references this issue on Aug 4, 2025
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

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions