Skip to content

Commit

Permalink
Add __iNtErNaL_running_procs
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Sep 12, 2023
1 parent 78112a1 commit 89129fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Malt"
uuid = "36869731-bdee-424d-aa32-cab38c994e3b"
authors = ["Sergio Alejandro Vargas <[email protected]>"]
version = "1.0.0"
version = "1.0.1"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
7 changes: 7 additions & 0 deletions src/Malt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ end

Base.summary(io::IO, w::InProcessWorker) = write(io, "Malt.InProcessWorker in module $(w.host_module)")

const __iNtErNaL_running_procs = Set{Base.Process}()
__iNtErNaL_get_running_procs() = filter!(Base.process_running, __iNtErNaL_running_procs)

"""
Malt.Worker()
Expand All @@ -98,6 +101,10 @@ mutable struct Worker <: AbstractWorker
# Spawn process
cmd = _get_worker_cmd(; env, exeflags)
proc = open(cmd, "w+")

# Keep internal list
__iNtErNaL_get_running_procs()
push!(__iNtErNaL_running_procs, proc)

# Block until reading the port number of the process (from its stdout)
port_str = readline(proc)
Expand Down
2 changes: 2 additions & 0 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
w = W()
@test m.isrunning(w) === true

W === m.Worker && @test length(m.__iNtErNaL_get_running_procs()) == 1
# Terminating workers takes about 0.5s
m.stop(w)
@test m.isrunning(w) === false
W === m.Worker && @test length(m.__iNtErNaL_get_running_procs()) == 0
end


Expand Down
9 changes: 8 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import Malt as m
using Test


v() = @assert isempty(m.__iNtErNaL_get_running_procs())

v()
include("basic.jl")
v()
include("exceptions.jl")
v()
include("nesting.jl")
v()
include("benchmark.jl")

v()


#TODO:
Expand Down

2 comments on commit 89129fa

@fonsp
Copy link
Member Author

@fonsp fonsp commented on 89129fa Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/91293

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.1 -m "<description of version>" 89129fa7a64388865f03f787ea12bd09d5af276c
git push origin v1.0.1

Please sign in to comment.