Skip to content

Commit 4d04309

Browse files
committed
force a single thread on windows
1 parent 73c2a68 commit 4d04309

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.github/workflows/Test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
julia-version: [1.6, 1.7]
9-
os: [ubuntu-latest, macOS-latest]
9+
os: [ubuntu-latest, macOS-latest, windows-latest]
1010
steps:
1111
- uses: actions/checkout@v1.0.0
1212
- uses: azure/login@v1.1

src/AzStorage.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ Base.close(object::AzObject) = nothing
8484

8585
const __OAUTH_SCOPE = "offline_access+openid+https://storage.azure.com/user_impersonation"
8686

87+
function windows_one_thread(nthreads)
88+
if Sys.iswindows() && nthreads != 1
89+
@warn "On Windows, AzStorage is limited to a single thread."
90+
end
91+
Sys.iswindows() ? 1 : nthreads
92+
end
93+
8794
"""
8895
container = AzContainer("containername"; storageaccount="myacccount", kwargs...)
8996
@@ -105,7 +112,7 @@ function AzContainer(containername::AbstractString; storageaccount, session=AzSe
105112
name = split(containername, '/')
106113
_containername = name[1]
107114
prefix *= lstrip('/'*join(name[2:end], '/'), '/')
108-
AzContainer(String(storageaccount), String(_containername), String(prefix), session, nthreads, nretry, verbose)
115+
AzContainer(String(storageaccount), String(_containername), String(prefix), session, windows_one_thread(nthreads), nretry, verbose)
109116
end
110117

111118
function AbstractStorage.Container(::Type{<:AzContainer}, d::Dict, session=AzSession(;lazy=true, scope=__OAUTH_SCOPE); nthreads = Sys.CPU_THREADS, nretry=10, verbose=0)
@@ -114,7 +121,7 @@ function AbstractStorage.Container(::Type{<:AzContainer}, d::Dict, session=AzSes
114121
d["containername"],
115122
d["prefix"],
116123
session,
117-
get(d, "nthreads", nthreads),
124+
windows_one_thread(get(d, "nthreads", nthreads)),
118125
get(d, "nretry", nretry),
119126
get(d, "verbose", verbose))
120127
end

test/runtests.jl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ sleep(60)
1616

1717
@testset "Error codes" begin
1818
@test unsafe_load(cglobal((:N_HTTP_RETRY_CODES, AzStorage.libAzStorage), Cint)) == 2
19-
x = unsafe_load(cglobal((:HTTP_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clong}))
19+
x = Sys.iswindows() ? unsafe_load(cglobal((:HTTP_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clonglong})) : unsafe_load(cglobal((:HTTP_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clong}))
2020
y = unsafe_wrap(Array, x, (2,); own=false)
2121
@test y == [500,503]
2222

2323
@test unsafe_load(cglobal((:N_CURL_RETRY_CODES, AzStorage.libAzStorage), Cint)) == 5
24-
x = unsafe_load(cglobal((:CURL_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clong}))
24+
x = Sys.iswindows() ? unsafe_load(cglobal((:CURL_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clonglong})) : unsafe_load(cglobal((:CURL_RETRY_CODES, AzStorage.libAzStorage), Ptr{Clong}))
2525
y = unsafe_wrap(Array, x, (5,); own=false)
2626
@test y == [6,7,28,55,56]
2727
end
@@ -240,7 +240,11 @@ end
240240
@test _c.storageaccount == storageaccount
241241
@test _c.containername == "foo-$r-k"
242242
@test _c.nretry == 10
243-
@test _c.nthreads == 2
243+
if Sys.iswindows()
244+
@test _c.nthreads == 1
245+
else
246+
@test _c.nthreads == 2
247+
end
244248
rm(c)
245249
end
246250

@@ -478,7 +482,8 @@ end
478482
rm(c)
479483
end
480484

481-
@testset "Container,Object, copy blob to blob" begin sleep(1)
485+
@testset "Container,Object, copy blob to blob" begin
486+
sleep(1)
482487
r = lowercase(randstring(MersenneTwister(millisecond(now())+33)))
483488
c = AzContainer("foo-$r-o", storageaccount=storageaccount, session=session, nthreads=2, nretry=10)
484489
mkpath(c)
@@ -487,3 +492,14 @@ end
487492
@test read(open(c, "bar.txt"), String) == "Hello world"
488493
rm(c)
489494
end
495+
496+
@testset "Windows, single thread check" begin
497+
sleep(1)
498+
r = lowercase(randstring(MersenneTwister(millisecond(now())+34)))
499+
container = AzContainer("foo-$r.o", storageaccount=storageaccount, session=session, nthreads=2, nretry=10)
500+
if Sys.iswindows()
501+
@test container.nthreads == 1
502+
else
503+
@test container.nthreads == 2
504+
end
505+
end

0 commit comments

Comments
 (0)