Permalink
Browse files

Add a retry to unreliable supd calls

  • Loading branch information...
1 parent 7dff00d commit 22e1d8debed3536c5648eef521881cd840be366f @oldpatricka oldpatricka committed Sep 6, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 pidantic/supd/supd.py
View
@@ -6,6 +6,7 @@
import StringIO
import logging
import fcntl
+import sys
import os
from pidantic.pidantic_exceptions import PIDanticUsageException, PIDanticExecutionException
from pidantic.supd.persistence import SupDDataObject, SupDProgramDataObject
@@ -127,7 +128,7 @@ def _add_process(self, sup, name):
def _reread(self):
sup = self._proxy.supervisor
try:
- rc = sup.reloadConfig()
+ rc = retry_supd_ten_times(sup.reloadConfig)
except xmlrpclib.Fault, e:
raise
(added, changed, removed) = rc[0]
@@ -263,6 +264,16 @@ def get_name(self):
def get_error_message(self):
return ""
+def retry_supd_ten_times(fn, *args, **kwargs):
+ exc = None
+ for i in range(0, 10):
+ try:
+ return fn(*args, **kwargs)
+ except xmlrpclib.ProtocolError, e:
+ exc = e
+ print >> sys.stderr, e
+ else:
+ raise exc
def _run_log(cmd, log):
#p = Popen(cmd, shell=True)

0 comments on commit 22e1d8d

Please sign in to comment.