Skip to content

Commit 4bb558a

Browse files
DilumAluthgeMoelf
andauthored
Don't do bare using Foo (#12)
* Don't do bare `using Foo` --------- Co-authored-by: Jerry Ling <proton@jling.dev>
1 parent 55110d7 commit 4bb558a

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/ElasticClusterManager.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
module ElasticClusterManager
22

3-
using Distributed
4-
using Sockets
3+
# We don't do `using Foo`
4+
# We either do `using Foo: bar`, or we do `import Foo`
5+
# https://github.com/JuliaLang/julia/pull/42080
6+
7+
import Distributed
8+
import Sockets
59
import Pkg
610

7-
export launch, manage, kill, init_worker, connect
11+
# Bring some names into scope, just for convenience:
12+
using Distributed: launch, manage, kill, init_worker, connect
813

14+
export launch, manage, kill, init_worker, connect
915
export ElasticManager, elastic_worker
1016

11-
import Distributed: launch, manage, kill, init_worker, connect
12-
1317
function worker_cookie()
1418
Distributed.init_multi()
1519
return Distributed.cluster_cookie()

src/elastic.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ else
1111
my_errormonitor(t) = nothing
1212
end
1313

14-
struct ElasticManager <: ClusterManager
15-
active::Dict{Int, WorkerConfig} # active workers
16-
pending::Channel{TCPSocket} # to be added workers
14+
struct ElasticManager <: Distributed.ClusterManager
15+
active::Dict{Int, Distributed.WorkerConfig} # active workers
16+
pending::Channel{Sockets.TCPSocket} # to be added workers
1717
terminated::Set{Int} # terminated worker ids
1818
topology::Symbol
1919
sockname
@@ -38,7 +38,7 @@ struct ElasticManager <: ClusterManager
3838

3939
t1 = @async begin
4040
while true
41-
let s = accept(l_sock)
41+
let s = Sockets.accept(l_sock)
4242
t2 = @async process_worker_conn(lman, s)
4343
my_errormonitor(t2)
4444
end
@@ -83,7 +83,7 @@ function process_pending_connections(mgr::ElasticManager)
8383
while true
8484
wait(mgr.pending)
8585
try
86-
addprocs(mgr; topology=mgr.topology)
86+
Distributed.addprocs(mgr; topology=mgr.topology)
8787
catch e
8888
showerror(stderr, e)
8989
Base.show_backtrace(stderr, Base.catch_backtrace())
@@ -144,7 +144,7 @@ function elastic_worker(cookie, addr="127.0.0.1", port=9009; stdout_to_master=tr
144144
c = connect(addr, port)
145145
write(c, rpad(cookie, HDR_COOKIE_LEN)[1:HDR_COOKIE_LEN])
146146
stdout_to_master && redirect_stdout(c)
147-
start_worker(c, cookie)
147+
Distributed.start_worker(c, cookie)
148148
end
149149

150150
function get_connect_cmd(em::ElasticManager; absolute_exename=true, same_project=true)

test/elastic.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# launch worker
88
old_cmd = ElasticClusterManager.get_connect_cmd(em)
99
new_cmd = `$(old_cmd) --coverage=user`
10-
run(`sh -c $(new_cmd)`, wait=false)
10+
# run(`sh -c $(new_cmd)`) # comment out this line when you are finished debugging
11+
run(`sh -c $(new_cmd)`; wait=false) # uncomment this line when you are finished debugging
1112

1213
# wait at most TIMEOUT seconds for it to connect
1314
@test :ok == timedwait(TIMEOUT) do

0 commit comments

Comments
 (0)