timholy / ProgressMeter.jl

Progress meter for long-running computations
MIT License
694 stars 91 forks source link

fail at the example for distributed for loop reduce in readme #243

Closed FuZhiyu closed 8 months ago

FuZhiyu commented 2 years ago

Sorry if it's already in the issues.

@everywhere using ProgressMeter
result = @showprogress 1 "Computing..." @distributed (+) for i in 1:10
           sleep(0.1)
           i^2
end

This example doesn't work in my case. Error:

nested task error: On worker 2:
UndefVarError: #3#ch not defined

My julia version:

Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, westmere)
Environment:
  JULIA_NUM_THREADS = 4
MarcMush commented 1 year ago

I could reproduce this in the REPL and in the global scope. It doesn't happen in a function or a local scope:

using Distributed
addprocs(2)

@everywhere using ProgressMeter
let a = 0
    result = @showprogress "Computing..." @distributed (+) for i in 1:10
        sleep(0.1)
        i^2
    end
end