fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] try/except not working as expected.


From: Morgan Goose
Subject: Re: [Fab-user] try/except not working as expected.
Date: Fri, 22 Oct 2010 08:48:13 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

If you dig into the code of the get function it swallows the exception. And
doesn't re-raise what it catches, so no exception on the fabfile level is going
to occur, so there is nothing to catch in spot where you're trying.

Using warn_only or not using it only toggles the use of the returning function
from the error handler from warn() to abort(). I think that you're going to
have to do your own error checking, and see if the file exists, unless anyone
has a better idea.

goose

On Fri, Oct 22, 2010 at 08:28:42AM -0400, Jeff Honey wrote:
> I have a function that isn't working as I would expect. I 'try' a get(), 
> which fails since the system isn't ready, and I try to catch that exception 
> but it doesn't seem to be working. I tried adding warn_only=True to keep 
> Fabric from exiting on an error but that didn't seem to help.
> 
> I tried to boil it down to the most common denominator but it is still 
> exiting entirely. This is, likely, just my never using the 'try' expression 
> before. The snippet below isn't what I started with but is what I have in my 
> code now...I know i shouldn't have a bare except as that is a dangerous way 
> to get stuck but I was grasping at straws.
> 
> Maybe I should be asking this elsewhere but the majority of the expressions 
> I've got are unique to Fabric...all I am looking to accomplish is run my 
> get(), catch any exception, and then retry the get() until success. Once that 
> works, I can think about adding some sort of retry timer so it won't get 
> stuck forever inside the expression.
> 
> 
> <snip>
> def is_ready():
>  with settings(
>   hide('warnings', 'running', 'stdout', 'stderr'),
>   warn_only=True
>  ):
>   try:
>    get('/tmp/ready.txt','~/') 
>   except:
>    time.sleep(10)
>    get('/tmp/ready.txt','~/')
> </snip>
> 
> 
> 
> --
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> ¤ kyoboku kazeoshi ¤
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
---end quoted text---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]