Skip to content

Commit 3a5b9b7

Browse files
committed
Log caller if blocked on wait.
1 parent 3f54989 commit 3a5b9b7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/async/container/forked.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def restart!
235235
# @returns [::Process::Status] The process exit status.
236236
def wait(timeout = 0.1)
237237
if @pid && @status.nil?
238-
Console.debug(self, "Waiting for process to exit...", pid: @pid)
238+
Console.debug(self, "Waiting for process to exit...", child: {process_id: @pid}, timeout: timeout)
239239

240240
_, @status = ::Process.wait2(@pid, ::Process::WNOHANG)
241241

@@ -245,7 +245,7 @@ def wait(timeout = 0.1)
245245
_, @status = ::Process.wait2(@pid, ::Process::WNOHANG)
246246

247247
if @status.nil?
248-
Console.warn(self) {"Process #{@pid} is blocking, sending kill signal..."}
248+
Console.warn(self, "Process is blocking, sending kill signal...", child: {process_id: @pid}, caller: caller_locations, timeout: timeout)
249249
self.kill!
250250

251251
# Wait for the process to exit:
@@ -254,7 +254,7 @@ def wait(timeout = 0.1)
254254
end
255255
end
256256

257-
Console.debug(self, "Process exited.", pid: @pid, status: @status)
257+
Console.debug(self, "Process exited.", child: {process_id: @pid, status: @status})
258258

259259
return @status
260260
end

lib/async/container/threaded.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,19 @@ def restart!
222222
# @returns [Status]
223223
def wait(timeout = 0.1)
224224
if @waiter
225-
Console.debug(self, "Waiting for thread to exit...", timeout: timeout)
225+
Console.debug(self, "Waiting for thread to exit...", child: {thread_id: @thread.object_id}, timeout: timeout)
226226

227227
unless @waiter.join(timeout)
228-
Console.warn(self) {"Thread #{@thread} is blocking, sending kill signal..."}
228+
Console.warn(self, "Thread is blocking, sending kill signal...", child: {thread_id: @thread.object_id}, caller: caller_locations, timeout: timeout)
229229
self.kill!
230230
@waiter.join
231231
end
232232

233233
@waiter = nil
234234
end
235235

236+
Console.debug(self, "Thread exited.", child: {thread_id: @thread.object_id, status: @status})
237+
236238
return @status
237239
end
238240

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Log caller and timeout when waiting on a child instance to exit, if it blocks.
6+
37
## v0.27.0
48

59
- Increased default interrupt timeout and terminate timeout to 10 seconds each.

0 commit comments

Comments
 (0)