Skip to content

Instantly share code, notes, and snippets.

@hoverlover
Last active December 15, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoverlover/92cd2c843cb9cec45eff to your computer and use it in GitHub Desktop.
Save hoverlover/92cd2c843cb9cec45eff to your computer and use it in GitHub Desktop.
============== timer started
timed out!
timed_out: false
require "pry-nav"
require 'rufus-json/automatic'
require 'ruote'
require 'ruote/storage/fs_storage'
ruote = Ruote::Dashboard.new(
Ruote::Worker.new(
Ruote::FsStorage.new('ruote_work')))
ruote.noisy = false
class StartTimer < Ruote::Participant
def on_workitem
puts "============== timer started"
end
end
ruote.register :start_timer, StartTimer
pdef = Ruote.define do
define "time_it_out" do
echo "timed out!"
rset "v:/timed_out" => true
end
# Autonomous participant
start_timer forget: true, timers: "2s: time_it_out"
# ... continue on with other things
# This wait is to give the start_timer time to actually time out
wait "5s"
# Here is where I would check the timed_out variable, and act accordingly.
# I expect this to be true, but is false
echo "timed_out: ${v:/timed_out}"
end
wfid = ruote.launch pdef, {}, { timed_out: false }
ruote.wait_for(wfid)
@jmettraux
Copy link

Hello Chad,

if there are no answers in the #ruote channel in IRC, feel free to use ruote's mailing-list: http://groups.google.com/group/openwferu-users

Your "time_it_out" process is executing attached to "start_timer" which is forgotten. A forgotten branch/subprocess has no access to its parent subprocess (it might be already gone), so setting /timed_out happens in the root of the "time_it_out" subprocess which is, the "start_timer" expression.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment