Process.run is blocking all other Fibers on Windows

def worker
  loop do
    {% if flag?(:win32) %}
      p Process.run("D:/windows/tool.exe", ["-version"]).exit_code
    {% else %}
      p Process.run("/d/linux/tool", ["-version"]).exit_code
    {% end %}
  end
end

spawn do
  worker
end

spawn do
  worker
end

i = 0

loop do
  p i
  i += 1
  sleep 0.1
end

Running the above code on linux works as expected (the two fibers getting the version of a tool, main fiber increments i value concurrently).

On windows it seems that the method Process.run is blocking the Scheduler. While the process is running the external command, no other fiber is scheduled, thus generating some output.

P.S:
Crystal 1.10.1 [c6f3552] (2023-10-13)

LLVM: 17.0.2
Default target: x86_64-pc-windows-msvc

This should have been fixed on master: Make `Process#wait` asynchronous on Windows by HertzDevil · Pull Request #13908 · crystal-lang/crystal · GitHub

1 Like

Does the version Crystal 1.10.1 [c6f3552] (2023-10-13) contains this fix ?

The above link says " @straight-shoota straight-shoota added this to the 1.11.0 milestone on Oct 27"

When will the version 1.11.0 be released ?

We have a release per quarter. The next one is scheduled for early January (we will soon publish the exact dates).

EDIT: more precision

Please note you can easily install nightly releases from Install Nightly Builds - The Crystal Programming Language

Thanks for this hint !

With the nightly build, the above code is working as expected !

1 Like