Skip to content

graphify update waits forever on Windows when the filesystem has no byte-range locks (e.g. \wsl.localhost) #4924

Closed

Description

@AndresDiagoM

What happened?

On Windows, graphify update . never finishes when the repo lives on a filesystem that does not support byte-range locks. The one I hit is the WSL share (\\wsl.localhost\<distro>\...), i.e. a repo inside WSL opened from Windows.

_rebuild_lock (graphify/watch.py) takes the Windows lock with msvcrt.locking(fd, LK_NBLCK, 1). On the WSL share that call raises OSError: [Errno 22] Invalid argument every time, not only under contention. The Windows branch treats any OSError as "another rebuild holds the lock":

  • blocking=True (what the graphify update CLI uses, block_on_lock=True in cli.py) retries in a while True with time.sleep(0.05) and no limit, so the process sleeps forever.
  • blocking=False (the git hooks, which call _rebuild_code with the default) yields False: the hook queues its change, prints "Rebuild already in progress … changes queued" and returns. No lock holder ever exists to drain that queue, so nothing gets rebuilt.

The POSIX branch only treats BlockingIOError as contention; other errors propagate. The asymmetry is what turns "this filesystem can't lock" into an infinite wait on Windows.

On my machine a SessionEnd hook that runs graphify update . --force hung like this 3 times out of 3 when the repo was opened from Windows through \\wsl.localhost: one run never logged an exit, one was killed after 4.5 h, and one ran for 33 h until I killed it. The same rebuild run inside WSL finishes in about 2 minutes.

Steps to reproduce

  1. On Windows with WSL, create a small repo inside the distro, e.g. 40 one-function .py files under /home/<user>/repro/pkg/.
  2. From Windows (PowerShell), cd \\wsl.localhost\Ubuntu\home\<user>\repro and run graphify update . --force.
  3. It prints the startup lines and then sits there. After 240 s it had used 0.7 s of CPU in total.

Control: the same repo copied to C: finishes in 4 s. Run inside WSL, it also finishes normally.

The lock call on its own, no graphify involved:

import msvcrt
fh = open(r"\\wsl.localhost\Ubuntu\home\<user>\repro\t.lock", "a+")
fh.seek(4096)
msvcrt.locking(fh.fileno(), msvcrt.LK_NBLCK, 1)   # OSError: [Errno 22] Invalid argument

On C: or D: the same call succeeds. A real contended lock (a second handle on a locked byte) raises [Errno 13] (EACCES), so the two cases can be told apart.

Error output or graph output

No error. A faulthandler.dump_traceback_later dump of the stuck process (0.9.94 line numbers):

File "...\graphify\watch.py", line 286 in _rebuild_lock
File "...\contextlib.py", line 137 in __enter__
File "...\graphify\watch.py", line 1728 in _rebuild_code
File "...\graphify\cli.py", line 2838 in dispatch_command
File "...\graphify\__main__.py", line 1101 in _run_cli

Graphify version

Hit on 0.9.94. The code is unchanged on v8 at 0.9.100 (watch.py lines 283-296).

Operating System

Windows 11 Pro (Insider build 26340), WSL 3.0.3, Ubuntu distro.

Python Version

3.11

Installation Method

pip

Additional context

Related: #3881 / #3883 added the msvcrt lock; #4273 is the POSIX-side lock fix. I have a fix with a regression test and will open a PR.

Activity

  1. github-actions commented on Nov 1, 2026

    @github-actions

    Thanks for opening this issue, @AndresDiagoM. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. added a commit that references this issue on Nov 2, 2026
    7750ba8
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions