Module: LLM::Tool::Utils
Overview
Shared utilities for tool implementations.
Instance Method Summary collapse
- #now ⇒ Numeric
-
#wait(command:, timeout:) ⇒ void
Wait for a command to finish, or abort with an error when it exceeds the specified timeout.
Instance Method Details
#now ⇒ Numeric
27 28 29 |
# File 'lib/llm/tools/utils.rb', line 27 def now Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
#wait(command:, timeout:) ⇒ void
This method returns an undefined value.
Wait for a command to finish, or abort with an error when it exceeds the specified timeout.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/llm/tools/utils.rb', line 14 def wait(command:, timeout:) start = now while command.running? if now - start > timeout command.kill! raise "command timed out after #{timeout}s" end sleep 0.01 end end |