Skip to content

Commit

Permalink
Display pid in summary(worker) (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Sep 27, 2023
1 parent bc80bea commit 20f8218
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Malt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Malt.Worker(0x0000, Process(`…`, ProcessRunning))
mutable struct Worker <: AbstractWorker
port::UInt16
proc::Base.Process
proc_pid::Int32

current_socket::Sockets.TCPSocket
# socket_lock::ReentrantLock
Expand Down Expand Up @@ -117,7 +118,14 @@ mutable struct Worker <: AbstractWorker

# There's no reason to keep the worker process alive after the manager loses its handle.
w = finalizer(w -> @async(stop(w)),
new(port, proc, socket, MsgID(0), Dict{MsgID,Channel{WorkerResult}}())
new(
port,
proc,
getpid(proc),
socket,
MsgID(0),
Dict{MsgID,Channel{WorkerResult}}(),
)
)
atexit(() -> stop(w))

Expand All @@ -127,7 +135,7 @@ mutable struct Worker <: AbstractWorker
end
end

Base.summary(io::IO, w::Worker) = write(io, "Malt.Worker on port $(w.port)")
Base.summary(io::IO, w::Worker) = write(io, "Malt.Worker on port $(w.port) with PID $(w.proc_pid)")


function _receive_loop(worker::Worker)
Expand Down

0 comments on commit 20f8218

Please sign in to comment.