fab-user
[Top][All Lists]
Advanced

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

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


From: Jeff Honey
Subject: [Fab-user] try/except not working as expected.
Date: Fri, 22 Oct 2010 08:28:42 -0400

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 ¤
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


reply via email to

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