projects
/
osm
/
N2VC.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
77e2f13
)
Retry calls to charmstore and increase timeout to 5s
author
Cory Johns
<johnsca@gmail.com>
Fri, 3 Mar 2017 16:16:04 +0000
(11:16 -0500)
committer
Cory Johns
<johnsca@gmail.com>
Fri, 3 Mar 2017 16:33:39 +0000
(11:33 -0500)
juju/model.py
patch
|
blob
|
history
diff --git
a/juju/model.py
b/juju/model.py
index
91aba25
..
812f35b
100644
(file)
--- a/
juju/model.py
+++ b/
juju/model.py
@@
-13,7
+13,8
@@
from functools import partial
from pathlib import Path
import yaml
from pathlib import Path
import yaml
-from theblues import charmstore
+import theblues.charmstore
+import theblues.errors
from .client import client
from .client import watcher
from .client import client
from .client import watcher
@@
-1760,7
+1761,7
@@
class CharmStore(object):
"""
def __init__(self, loop):
self.loop = loop
"""
def __init__(self, loop):
self.loop = loop
- self._cs =
charmstore.CharmStore(
)
+ self._cs =
theblues.charmstore.CharmStore(timeout=5
)
def __getattr__(self, name):
"""
def __getattr__(self, name):
"""
@@
-1774,7
+1775,13
@@
class CharmStore(object):
else:
async def coro(*args, **kwargs):
method = partial(attr, *args, **kwargs)
else:
async def coro(*args, **kwargs):
method = partial(attr, *args, **kwargs)
- return await self.loop.run_in_executor(None, method)
+ for attempt in range(1, 4):
+ try:
+ return await self.loop.run_in_executor(None, method)
+ except theblues.errors.ServerError:
+ if attempt == 3:
+ raise
+ await asyncio.sleep(1, loop=self.loop)
setattr(self, name, coro)
wrapper = coro
return wrapper
setattr(self, name, coro)
wrapper = coro
return wrapper