Skip to content

Commit

Permalink
Try to fix FileWatching test more (JuliaLang#46524)
Browse files Browse the repository at this point in the history
I think the synchronization in JuliaLang#46028 was incomplete to actually fix
the issue. Try to fix it by accounting the time taken to wait for
the synchronization event into the lock time. Otherwise, the test
pass/fail depends on the scheduler ordering.
  • Loading branch information
Keno authored Aug 29, 2022
1 parent 5316549 commit 3037c0a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions stdlib/FileWatching/test/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,17 @@ end
# Just for coverage's sake, run a test with do-block syntax
lock_times = Float64[]
synchronizer = Base.Event()
synchronizer2 = Base.Event()
t_loop = @async begin
wait(synchronizer)
for idx in 1:100
t = @elapsed mkpidlock("do_block_pidfile") do
# nothing
t = @elapsed begin
if idx == 1
wait(synchronizer)
notify(synchronizer2)
end
mkpidlock("do_block_pidfile") do
# nothing
end
end
sleep(0.01)
push!(lock_times, t)
Expand All @@ -286,6 +292,7 @@ end
isdefined(Base, :errormonitor) && Base.errormonitor(t_loop)
mkpidlock("do_block_pidfile") do
notify(synchronizer)
wait(synchronizer2)
sleep(3)
end
wait(t_loop)
Expand Down

0 comments on commit 3037c0a

Please sign in to comment.