Class: Legate::Tools::SleepyWorker
- Inherits:
-
Object
- Object
- Legate::Tools::SleepyWorker
- Defined in:
- lib/legate/tools/sleepy_tool.rb
Overview
The worker that performs the actual sleep operation.
Instance Method Summary collapse
Instance Method Details
#perform(jid, duration, message) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/legate/tools/sleepy_tool.rb', line 47 def perform(jid, duration, ) # --- Store initial pending status --- # begin Legate::Tools::BaseAsyncJobTool.store_job_pending(jid) rescue StandardError => e # Log error but try to continue if possible Legate.logger.error("[SleepyWorker JID: #{jid}] Failed to store initial pending status: #{e.}") end # --- End store initial pending status --- # Legate.logger.info("[SleepyWorker JID: #{jid}] Starting job. Sleeping for #{duration} seconds...") begin sleep duration.to_i = "Slept for #{duration} seconds. Your message: #{}" Legate.logger.info("[SleepyWorker JID: #{jid}] Job finished. Storing result.") # Store the successful result using the helper from BaseAsyncJobTool Legate::Tools::BaseAsyncJobTool.store_job_result(jid, ) rescue StandardError => e = "Job failed after starting sleep: #{e.}" Legate.logger.error("[SleepyWorker JID: #{jid}] Job failed! Storing error. Error: #{}") # Store the error using the helper Legate::Tools::BaseAsyncJobTool.store_job_error(jid, , e.class.name) end end |