Ben Johnson
2006-Jul-31 20:06 UTC
[Backgroundrb-devel] delete_worker doesn''t kill the thread?
I made a worker that run an infinite loop and does the following:
while true
@logger << "logging #{Time.now}"
sleep 2
end
In my secong console I did:
tail log/backgroundrb.log -f
This is so I could see the line getting added to the log every 2
seconds.
Then in my other console I started script/console and created a new
worker. Then killed it with MiddleMan.delete_worker(job_key), where
job_key was the job key for the worker.
After I did that the other console that was monitoring my log
continued to add a line every 2 seconds, it didn''t stop.
Am I missing something here or shouldn''t deleting a worker stop the
loop and kill the thread?
Thanks for your help.
Thank You,
Ben Johnson
E: bjohnson at contuitive.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060731/6d22b016/attachment.html
Charles Brian Quinn
2006-Jul-31 23:07 UTC
[Backgroundrb-devel] delete_worker doesn''t kill the thread?
Couldn''t you do something like this:
# in your initalize worker put:
@running = true
in your main work method:
while @running
@logger << "logging #{Time.now}"
sleep 2
end
add a method:
def stop
@running = false
end
Now before deleting the worker, just call stop. I am curious about
the behavior you''re seeing, though.
On 7/31/06, Ben Johnson <bjohnson at contuitive.com>
wrote:>
> I made a worker that run an infinite loop and does the following:
>
> while true
> @logger << "logging #{Time.now}"
> sleep 2
> end
>
> In my secong console I did:
>
> tail log/backgroundrb.log -f
>
> This is so I could see the line getting added to the log every 2 seconds.
>
> Then in my other console I started script/console and created a new worker.
> Then killed it with MiddleMan.delete_worker(job_key), where job_key was the
> job key for the worker.
>
> After I did that the other console that was monitoring my log continued to
> add a line every 2 seconds, it didn''t stop.
>
> Am I missing something here or shouldn''t deleting a worker stop
the loop and
> kill the thread?
>
> Thanks for your help.
>
> Thank You,
> Ben Johnson
> E: bjohnson at contuitive.com
>
>
>
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
>
--
Charles Brian Quinn
www.seebq.com