george .
2006-Dec-15 04:21 UTC
[Backgroundrb-devel] can Timeout::timeout(...) be used in a Worker ?
Hi , I was wondering if anyone else has tried to use the Timeout::timeout method in a backgroundrb Worker and had Timeout raise an exception after the allotted amount of time . I ask because i have written a test script to make sure Timeout would work . I have tested the script by directly feeding it to ruby with : $ ruby test_script.rb and piping the script to the rails console: $ script/console < test_script.rb Both of which work as expected . I am using the latest release of backgroundrb: 0.2.1 (Released November 28, 2006 - r162) . If it is not possible to use TImeout::timeout in a Worker currently, is there another means to accomplish the same goal as Timeout::timeout ? thanks , george .
Charles Brian Quinn
2006-Dec-15 15:44 UTC
[Backgroundrb-devel] can Timeout::timeout(...) be used in a Worker ?
This doesn''t help at all, I know, but I use it in the older version of backgroundrb with no problems. Let us know your results, I don''t see why it wouldn''t work. On 12/14/06, george. <george at initiatecommerce.com> wrote:> Hi , > > I was wondering if anyone else has tried to use the Timeout::timeout > method in a backgroundrb Worker and had Timeout raise an exception > after the allotted amount of time . > I ask because i have written a test script to make sure Timeout would > work . I have tested the script by directly feeding it to ruby with : > $ ruby test_script.rb > > and piping the script to the rails console: > $ script/console < test_script.rb > > Both of which work as expected . > > I am using the latest release of backgroundrb: 0.2.1 (Released > November 28, 2006 - r162) . > > If it is not possible to use TImeout::timeout in a Worker currently, > is there another means to accomplish the same goal as Timeout::timeout ? > > thanks , > > > george . > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel >-- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com
skaar
2006-Dec-15 18:17 UTC
[Backgroundrb-devel] can Timeout::timeout(...) be used in a Worker ?
What is it that doesn''t work with Timeout::timeout? class TimeoutWorker < BackgrounDRb::Worker::Base require ''timeout'' def do_work(args) self.rescued_timeout #self.simple_timeout end def simple_timeout Timeout::timeout(5) { sleep 10 } end def rescued_timeout begin self.simple_timeout rescue Timeout::Error "timed out" end end end TimeoutWorker.register There is a number of things to notice with this. You need to make sure that to handle exceptions in do_work properly. ''do_work'' is called automatically as a backgrounded call, so an exception will never reach the caller. The work_thread worker method will terminate the worker on an unhandled exception. Above, I''ve commented out self.simple_timeout, since it would always result in the worker getting terminated. If you want to call worker(new_worker(:class => :timeout_worker, :job_key => :timeout)).simple_timeout directly, you will also need to require ''timeout'' on the caller side, otherwise Timeout::Error will be an unknown symbol for DRb. The resuced_timout method properly handle the exception in the worker. /skaar * george . (george at initiatecommerce.com) [061214 22:12]:> Hi , > > I was wondering if anyone else has tried to use the Timeout::timeout > method in a backgroundrb Worker and had Timeout raise an exception > after the allotted amount of time . > I ask because i have written a test script to make sure Timeout would > work . I have tested the script by directly feeding it to ruby with : > $ ruby test_script.rb > > and piping the script to the rails console: > $ script/console < test_script.rb > > Both of which work as expected . > > I am using the latest release of backgroundrb: 0.2.1 (Released > November 28, 2006 - r162) . > > If it is not possible to use TImeout::timeout in a Worker currently, > is there another means to accomplish the same goal as Timeout::timeout ? > > thanks , > > > george . > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel-- ---------------------------------------------------------------------- |\|\ where in the | s_u_b_s_t_r_u_c_t_i_o_n | | >=========== W.A.S.T.E. | genarratologies |/|/ (_) is the wisdom | skaar at waste.org ----------------------------------------------------------------------
george .
2006-Dec-19 21:39 UTC
[Backgroundrb-devel] can Timeout::timeout(...) be used in a Worker ?
I have been investigating the problem some more since the first reply . I have successfully been able to use sleep() and have Timeout work with no problems . So i began to dig deeper into the functions i am executing in the Timeout block . I have not found anything definitive yet but i want to share some more information in hopes that it might spark a new approach to troubleshooting the cause . First, here is some more information about the block of code i am executing inside the Timeout . I am working with FasterCSV and have a fairly large (~7mb) tab delimited file which is malformed and causes FasterCSV to not be so fast . I am attempting to wrap the parser.each method in a Timeout block for a reasonable amount of time , which should throw an exception if the parsing takes too long . However, this seems to not work when i am running in the context of Backgroundrb . I have verified this in both a Rails + Backgroundrb development environment and using "script/backgroundrb console" , both of which produce the same results (i.e. they have the same issue of not timing out) . After some time i got the feeling it was not just Backgroundrb which might be the issue but rather the combination of Backgroundrb and FasterCSV . Digging into the FasterCSV code i noticed it is using an underlying IO object and a few regular expressions to do the bulk of the processing work . I am now wondering if the IO.gets method or the regular expressions are not allowing the Timeout thread a chance to throw the exception . An interesting thing i did notice is if i add any BackgrounDRb::ServerLogger.logger.debug calls in the FasterCSV processing code the Timeout works as expected while in Backgroundrb , but when i take the logger calls out Timeout does not throw the exception . This is currently where i am . If someone has an idea of something else i can try to narrow down the problem please do let me know . thanks , george .
Apparently Analagous Threads
- Samba-tool gpo manage - The authenticated user does not have sufficient privileges
- Samba-tool gpo manage - The authenticated user does not have sufficient privileges
- Samba-tool gpo manage - The authenticated user does not have sufficient privileges
- Samba-tool gpo manage - The authenticated user does not have sufficient privileges
- How Can I insert another column data into the CSV file when I use FasterCSV?