I am trying to create a function to plug into a restart script I'm creating. I 
can't seem to successfully loop through making an http connection, if it fails 
to retry, if it succeeds, to end and continue with its parent function.

I'm  using the Fabric project's module and including my functions in fabfile.py.

the most rudimentary I've got right now is this:

<snip>

def is_ready():
 with settings(
  warn_only=True
 ):
  try:
   urllib2.urlopen('http://'+env.host_string+'\:8080') 
  except urllib2.URLError:
   time.sleep(10)
   urllib2.urlopen('http://'+env.host_string+'\:8080')
</snip>

I am trying to get the 'host_string' environment variable to plug in here but 
not sure if the parent function will pass along that information nor if I can 
call it like this. Additionally, I have never used try/except so I don't know 
if this will just try twice and quit. As it is now, it raises URLError and 
bombs out.


--
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
¤ kyoboku kazeoshi ¤
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to