[Backgroundrb-devel] can Timeout::timeout(...) be used in a Worker ?

george . george at initiatecommerce.com
Tue Dec 19 16:39:34 EST 2006


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 .


More information about the Backgroundrb-devel mailing list