Alan.Hayes at onevision.com
2008-Sep-13 20:10 UTC
[Backgroundrb-devel] Determining whether shared code is running in a worker
Hello Hemant et al - I have a module which is common to my foreground Rails code and some of my workers. Is there a way to determine whether I am running in a worker? I can''t use the session because not all my foreground code has a session; some is run as callbacks to the foreground and has no session. There may have been a question about this in the past, but, if so, I haven''t found it. Any suggestions are appreciated. Regards, alan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080913/2634926e/attachment.html>
hemant kumar
2008-Sep-14 02:22 UTC
[Backgroundrb-devel] Determining whether shared code is running in a worker
Sure, There are couple of ways: 1. worker_name method will be available inside your worker code and should be non nil. 2. If inside worker code, you will have access to many worker unique attributes (like thread_pool), you can check for those and make conditions. On Sat, 2008-09-13 at 16:10 -0400, Alan.Hayes at onevision.com wrote:> > Hello Hemant et al - > > I have a module which is common to my foreground Rails code > and some of my workers. Is there a way to determine whether I am > running in a worker? I can''t use the session because not all my > foreground code has a session; some is run as callbacks to the > foreground and has no session. There may have been a question about > this in the past, but, if so, I haven''t found it. Any suggestions are > appreciated. > > Regards, alan > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel