From a39dd6620d64897144ec552aabf5a0b63137a856 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 11:54:54 +0100 Subject: [PATCH 01/14] Replace UVError with IOError --- src/Pidfile.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Pidfile.jl b/src/Pidfile.jl index facd339..b470706 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -17,7 +17,7 @@ end end using Base: - UVError, UV_EEXIST, UV_ESRCH, + IOError, UV_EEXIST, UV_ESRCH, Process using Base.Filesystem: @@ -125,7 +125,7 @@ function parse_pidfile(path::String) close(existing) end catch ex - isa(ex, EOFError) || isa(ex, UVError) || rethrow(ex) + isa(ex, EOFError) || isa(ex, IOError) || rethrow(ex) return (Cuint(0), "", 0.0) end end @@ -175,7 +175,7 @@ function tryopen_exclusive(path::String, mode::Integer = 0o444) try return open(path, JL_O_RDWR | JL_O_CREAT | JL_O_EXCL, mode) catch ex - (isa(ex, UVError) && ex.code == UV_EEXIST) || rethrow(ex) + (isa(ex, IOError) && ex.code == UV_EEXIST) || rethrow(ex) end return nothing end @@ -202,7 +202,7 @@ function open_exclusive(path::String; t = @async try watch_file(path, poll_interval) catch ex - isa(ex, UVError) || rethrow(ex) + isa(ex, IOError) || rethrow(ex) sleep(poll_interval) # if the watch failed, convert to just doing a sleep end # now try again to create it @@ -217,7 +217,7 @@ function open_exclusive(path::String; try rm(path) catch ex - isa(ex, UVError) || rethrow(ex) + isa(ex, IOError) || rethrow(ex) end end end From 73253dbad504b976978186e6b766caf89fb64ace Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 12:44:31 +0100 Subject: [PATCH 02/14] Fix more depwarns --- src/Pidfile.jl | 2 +- test/runtests.jl | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Pidfile.jl b/src/Pidfile.jl index b470706..beed9f0 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -208,7 +208,7 @@ function open_exclusive(path::String; # now try again to create it file = tryopen_exclusive(path, mode) file === nothing || return file - wait(t) # sleep for a bit before trying again + fetch(t) # sleep for a bit before trying again if stale_age > 0 && stale_pidfile(path, stale_age) # if the file seems stale, try to remove it before attempting again # set stale_age to zero so we won't attempt again, even if the attempt fails diff --git a/test/runtests.jl b/test/runtests.jl index 1e2b630..56e1b17 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -109,7 +109,7 @@ end # release the pidfile after a short delay deleted = false - rmtask = @schedule begin + rmtask = @async begin sleep(3) rm("pidfile") deleted = true @@ -135,7 +135,7 @@ end close(f2) end rm("pidfile") - wait(rmtask) + fetch(rmtask) # now test with a long delay and other non-default options f = open_exclusive("pidfile", mode = 0o000)::File @@ -145,7 +145,7 @@ end close(f) end deleted = false - rmtask = @schedule begin + rmtask = @async begin sleep(8) rm("pidfile") deleted = true @@ -165,7 +165,7 @@ end close(f2) end rm("pidfile") - wait(rmtask) + fetch(rmtask) end @testset "open_exclusive: break lock" begin @@ -192,13 +192,13 @@ end end @testset "open_exclusive: other errors" begin - @test_throws(thrown_type(Base.UVError("open", Base.UV_ENOENT)), + @test_throws(thrown_type(Base.IOError("open: no such file or directory (ENOENT)", Base.UV_ENOENT)), open_exclusive("nonexist/folder")) end @testset "mkpidlock" begin lockf = mkpidlock("pidfile") - waittask = @schedule begin + waittask = @async begin sleep(3) cd(homedir()) do return close(lockf) @@ -206,7 +206,7 @@ end end t = @elapsed lockf1 = mkpidlock("pidfile") @test t > 2 - @test istaskdone(waittask) && wait(waittask) + @test istaskdone(waittask) && fetch(waittask) @test !close(lockf) finalize(lockf1) t = @elapsed lockf2 = mkpidlock("pidfile") From d5a1c35b6be30bfc1ae318f6c8c245e4cf973b87 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 12:45:44 +0100 Subject: [PATCH 03/14] Get it to work on 1.0 and put it on travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5898fa..1e93904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,7 @@ os: - linux - osx julia: - - 0.6 - - nightly + - 1.0 notifications: email: false git: From f33cc0e4a20517217932f8476f8adb8dccb590d1 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 12:56:47 +0100 Subject: [PATCH 04/14] Incorporate comments --- src/Pidfile.jl | 2 +- test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pidfile.jl b/src/Pidfile.jl index beed9f0..b470706 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -208,7 +208,7 @@ function open_exclusive(path::String; # now try again to create it file = tryopen_exclusive(path, mode) file === nothing || return file - fetch(t) # sleep for a bit before trying again + wait(t) # sleep for a bit before trying again if stale_age > 0 && stale_pidfile(path, stale_age) # if the file seems stale, try to remove it before attempting again # set stale_age to zero so we won't attempt again, even if the attempt fails diff --git a/test/runtests.jl b/test/runtests.jl index 56e1b17..b7b0a08 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -135,7 +135,7 @@ end close(f2) end rm("pidfile") - fetch(rmtask) + wait(rmtask) # now test with a long delay and other non-default options f = open_exclusive("pidfile", mode = 0o000)::File @@ -165,7 +165,7 @@ end close(f2) end rm("pidfile") - fetch(rmtask) + wait(rmtask) end @testset "open_exclusive: break lock" begin From 02c28b1ac72d550574765b13b24e0d82847c8478 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 13:00:19 +0100 Subject: [PATCH 05/14] Update travis --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e93904..7ce87f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,9 @@ julia: - 1.0 notifications: email: false -git: - depth: 99999999 after_success: # push coverage results to Coveralls - - julia -e 'cd(Pkg.dir("Pidfile")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' # push coverage results to Codecov - - julia -e 'cd(Pkg.dir("Pidfile")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' From 62515ff61a657b9239c40e6bfb1072561ab8d4cb Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 13:01:01 +0100 Subject: [PATCH 06/14] Appveyor from Glob.jl --- .appveyor.yml | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index e38d704..4d33905 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,13 +1,22 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" + - julia_version: 1 + - julia_version: nightly + +platform: + - x86 # 32-bit + - x64 # 64-bit + +# # Uncomment the following lines to allow failures on nightly julia +# # (tests will run but not make your overall status red) +# matrix: +# allow_failures: +# - julia_version: latest branches: only: - master + - /release-.*/ notifications: - provider: Email @@ -15,26 +24,19 @@ notifications: on_build_failure: false on_build_status_changed: false -init: - - git config --global core.autocrlf input - install: - - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" -# If there's a newer build queued for the same PR, cancel this one - - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` - Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` - throw "There are newer queued builds for this pull request, failing early." } -# Download most recent Julia Windows binary - - ps: (new-object net.webclient).DownloadFile( - $env:JULIA_URL, - "C:\projects\julia-binary.exe") -# Run installer silently, output to C:\projects\julia - - C:\projects\julia-binary.exe /S /D=C:\projects\julia + - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: - - C:\projects\julia\bin\julia -e "versioninfo(); - Pkg.clone(pwd(), \"Pidfile\"); Pkg.build(\"Pidfile\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - - C:\projects\julia\bin\julia -e "Pkg.test(\"Pidfile\")" + - echo "%JL_TEST_SCRIPT%" + - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" + +# # Uncomment to support code coverage upload. Should only be enabled for packages +# # which would have coverage gaps without running on Windows +# on_success: +# - echo "%JL_CODECOV_SCRIPT%" +# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%" From b3df883782f0123f5655b4a403ac3b8fa0e0ef8f Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 13:12:14 +0100 Subject: [PATCH 07/14] Modify REQUIRES to add 1.0 [ci skip] --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index b3a21b7..5f2b1ef 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia v0.6 +julia 1.0 Compat v0.30.0 From 43dccba7b15fb5ca1e9f5ef6c98795cb40ff6517 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 13:26:01 +0100 Subject: [PATCH 08/14] Make both lines consistent [ci skip] --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 5f2b1ef..bdf0390 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ julia 1.0 -Compat v0.30.0 +Compat 0.30.0 From db7c1f62897a74db7baaf289935ce21753ebc339 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Sat, 11 Aug 2018 15:06:15 +0100 Subject: [PATCH 09/14] support julia v0.7 --- .appveyor.yml | 1 + .travis.yml | 1 + REQUIRE | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4d33905..3c86871 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,5 +1,6 @@ environment: matrix: + - julia_version: 0.7 - julia_version: 1 - julia_version: nightly diff --git a/.travis.yml b/.travis.yml index 7ce87f5..8ba7c68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ os: - linux - osx julia: + - 0.7 - 1.0 notifications: email: false diff --git a/REQUIRE b/REQUIRE index bdf0390..0a85c17 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 1.0 +julia 0.7 Compat 0.30.0 From 436184efbd20b341bb3405f971b06841e1df91a7 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Sat, 11 Aug 2018 15:06:26 +0100 Subject: [PATCH 10/14] fix wait() -> fetch() deprecation --- src/Pidfile.jl | 2 +- test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pidfile.jl b/src/Pidfile.jl index b470706..beed9f0 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -208,7 +208,7 @@ function open_exclusive(path::String; # now try again to create it file = tryopen_exclusive(path, mode) file === nothing || return file - wait(t) # sleep for a bit before trying again + fetch(t) # sleep for a bit before trying again if stale_age > 0 && stale_pidfile(path, stale_age) # if the file seems stale, try to remove it before attempting again # set stale_age to zero so we won't attempt again, even if the attempt fails diff --git a/test/runtests.jl b/test/runtests.jl index b7b0a08..56e1b17 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -135,7 +135,7 @@ end close(f2) end rm("pidfile") - wait(rmtask) + fetch(rmtask) # now test with a long delay and other non-default options f = open_exclusive("pidfile", mode = 0o000)::File @@ -165,7 +165,7 @@ end close(f2) end rm("pidfile") - wait(rmtask) + fetch(rmtask) end @testset "open_exclusive: break lock" begin From 142e558aa8eeb28c3c9d076feb7b7d9a1a4e4853 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Sat, 11 Aug 2018 15:36:58 +0100 Subject: [PATCH 11/14] undo wait() -> fetch() change --- src/Pidfile.jl | 2 +- test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pidfile.jl b/src/Pidfile.jl index beed9f0..b470706 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -208,7 +208,7 @@ function open_exclusive(path::String; # now try again to create it file = tryopen_exclusive(path, mode) file === nothing || return file - fetch(t) # sleep for a bit before trying again + wait(t) # sleep for a bit before trying again if stale_age > 0 && stale_pidfile(path, stale_age) # if the file seems stale, try to remove it before attempting again # set stale_age to zero so we won't attempt again, even if the attempt fails diff --git a/test/runtests.jl b/test/runtests.jl index 56e1b17..b7b0a08 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -135,7 +135,7 @@ end close(f2) end rm("pidfile") - fetch(rmtask) + wait(rmtask) # now test with a long delay and other non-default options f = open_exclusive("pidfile", mode = 0o000)::File @@ -165,7 +165,7 @@ end close(f2) end rm("pidfile") - fetch(rmtask) + wait(rmtask) end @testset "open_exclusive: break lock" begin From 8b1e5daf771f37fd255177ab6d9c7f9c440acdf7 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Sat, 11 Aug 2018 22:54:27 +0100 Subject: [PATCH 12/14] Dial down REQUIRE to 0.7 --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index bdf0390..0a85c17 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 1.0 +julia 0.7 Compat 0.30.0 From 5945bad26bb9a03c005441d21fca267120449745 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Mon, 13 Aug 2018 14:14:27 +0530 Subject: [PATCH 13/14] Make travis test nightly too [ci skip] --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8ba7c68..f0b4362 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ os: julia: - 0.7 - 1.0 + - nightly notifications: email: false From 054fa3f1ae8d17ba37382f34c009e9f317c472b4 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Tue, 14 Aug 2018 21:30:46 +0530 Subject: [PATCH 14/14] Get rid of Compat --- REQUIRE | 1 - src/Pidfile.jl | 26 +------------------------- test/runtests.jl | 16 +++------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/REQUIRE b/REQUIRE index 0a85c17..859ad46 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1 @@ julia 0.7 -Compat 0.30.0 diff --git a/src/Pidfile.jl b/src/Pidfile.jl index b470706..49e1394 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -1,21 +1,9 @@ __precompile__() module Pidfile -if VERSION < v"0.7.0-DEV.1053" -using Compat # defines read(io, String) -end export mkpidlock -if VERSION < v"0.7.0-DEV.3107" -macro warn(msg) - return :(warn($(esc(msg)))) -end -macro info(msg) - return :(info($(esc(msg)))) -end -end - using Base: IOError, UV_EEXIST, UV_ESRCH, Process @@ -24,13 +12,8 @@ using Base.Filesystem: File, open, JL_O_CREAT, JL_O_RDWR, JL_O_RDONLY, JL_O_EXCL, samefile -if VERSION < v"0.7.0-DEV.914" -using Base.Filesystem: watch_file -const iswindows = Sys.is_windows -else using FileWatching: watch_file using Base.Sys: iswindows -end """ mkpidlock(at::String, [pid::Cint, proc::Process]; kwopts...) @@ -60,11 +43,7 @@ mutable struct LockMonitor try write_pidfile(fd, pid) lock = new(at, fd) - if VERSION < v"0.7.0-DEV.2562" - finalizer(lock, close) - else - finalizer(close, lock) - end + finalizer(close, lock) catch ex close(fd) rm(at) @@ -107,9 +86,6 @@ function parse_pidfile(io::IO) fields = split(read(io, String), ' ', limit = 2) pid = tryparse(Cuint, fields[1]) pid === nothing && (pid = Cuint(0)) - if VERSION < v"0.7" && !isa(pid, Cuint) - pid = get(pid, Cuint(0)) - end hostname = (length(fields) == 2) ? fields[2] : "" when = mtime(io) age = time() - when diff --git a/test/runtests.jl b/test/runtests.jl index b7b0a08..c382109 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,13 +1,7 @@ using Pidfile -if VERSION < v"0.7.0-DEV.2005" - using Base.Test - thrown_type(x::Exception) = typeof(x) - thrown_type(x::Type) = x -else - using Test - thrown_type(x) = x -end +using Test +thrown_type(x) = x using Base.Filesystem: File using Pidfile: iswindows, @@ -76,11 +70,7 @@ end @testset "parse_pidfile" begin age = 0 - if VERSION < v"0.7-" - @test parse_pidfile("nonexist") == (Cuint(0), "", 0.0) - else - @test parse_pidfile("nonexist") === (Cuint(0), "", 0.0) - end + @test parse_pidfile("nonexist") === (Cuint(0), "", 0.0) open(io -> write_pidfile(io, pid), "pidfile", "w") pid2, host2, age2 = parse_pidfile("pidfile") @test pid == pid2