<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'm using backgroundrb for session management and 
deletion of visitor-entered information when a session is abandoned.&nbsp; The 
visitor can either click a button to end their session and remove their data, or 
backgroundrb will do it for them after 5 minutes of inactivity.&nbsp; 
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Everything's working fine, I think.&nbsp; If the 
visitor explicitly logs out, then when the worker checks for their record it 
won't be there which will trigger logic that says 'you're done. close the 
connection and kill yourself'.&nbsp; What makes me a little worried is that I'm 
getting what looks like an error message in backgroundrb.log.&nbsp; I've 
included it below.&nbsp; I've also included the worker code.&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Can anybody tell me how to verify that the worker 
is actually closing the connection and then creating suicide?&nbsp; Versus dying 
because of this failed find and not closing the connection 
correctly?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Bill</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>----------- log message -----------</FONT></DIV>
<DIV><FONT face=Arial size=2>Couldn't find Emrec with ID=1 - 
(ActiveRecord::RecordNotFound)<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:955:in 
`find_one'<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:941:in 
`find_from_ids'<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:382:in 
`find'<BR>./script/backgroundrb/../../config/../lib/workers/session_worker.rb:20:in 
`watch_session'<BR>./script/backgroundrb/../../config/../lib/workers/session_worker.rb:12:in 
`do_work'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:36:in 
`start_process'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:32:in 
`start_process'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:57:in 
`new_worker'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/thread.rb:135:in 
`synchronize'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:49:in 
`new_worker'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1552:in 
`perform_without_block'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1512:in 
`perform'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1586:in 
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1582:in 
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1578:in 
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1427:in 
`run'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1424:in 
`run'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1344:in 
`initialize'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1624:in 
`start_service'<BR>script/backgroundrb/start:108<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>------------ Worker code ----------</FONT></DIV>
<DIV><FONT face=Arial size=2>class SessionWorker &lt; 
BackgrounDRb::Rails<BR>&nbsp;<BR>&nbsp; attr_reader 
:time_remaining<BR></FONT><FONT face=Arial size=2>&nbsp;<BR>&nbsp; def 
do_work(args)<BR>&nbsp;&nbsp;&nbsp; @time_remaining = 
args[:initial_setting].to_i<BR>&nbsp;&nbsp;&nbsp; @emrec_id = 
args[:emrec_id]<BR>&nbsp;&nbsp;&nbsp; @session_id = 
args[:session_id]&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; @session_rec = 
Session.find(:first,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
:conditions =&gt; ["sessid = ?", @session_id])&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; watch_session(args)<BR>&nbsp;&nbsp;&nbsp; 
sleep(2)<BR>&nbsp;&nbsp;&nbsp; clean_up&nbsp; <BR>&nbsp; 
end<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; def 
watch_session(args)<BR>&nbsp;&nbsp;&nbsp; while @time_remaining &gt; 
0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
emrec = Emrec.find(@emrec_id)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if emrec != 
nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if emrec.timer_suspended == 
'no'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; last_activity = 
emrec.last_updated_at<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
time_remaining_float = (last_activity + args[:initial_setting].to_i) - 
Time.now<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
@time_remaining = 
time_remaining_float.to_i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
end<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @time_remaining = 
0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<BR>&nbsp;&nbsp;&nbsp; end<BR>&nbsp; 
end<BR>&nbsp; <BR>&nbsp; def clean_up<BR>&nbsp;&nbsp;&nbsp; emrec = 
Emrec.find(@emrec_id)<BR>&nbsp;&nbsp;&nbsp; if emrec != 
nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
emrec.cleanup<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Session.delete(@session_rec.id)<BR>&nbsp;&nbsp;&nbsp; end<BR>&nbsp;&nbsp;&nbsp; 
ActiveRecord::Base.connection.disconnect!<BR>&nbsp;&nbsp;&nbsp; 
::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key<BR>&nbsp; 
end</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>end<BR></FONT></DIV></BODY></HTML>