Skip to content

Commit

Permalink
Merge pull request #1804 from dbungert/lp-2034715-just-wait-longer
Browse files Browse the repository at this point in the history
snapd api: wait longer
  • Loading branch information
dbungert authored Sep 22, 2023
2 parents d7f5ef1 + 5a573f2 commit 333e4d9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions subiquitycore/snapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@


class SnapdConnection:
# In LP: #2034715, we found that while some requests should be
# non-blocking, they are actually blocking and exceeding one minute.
# Extending the timeout helps.
default_timeout_seconds = 600

def __init__(self, root, sock):
self.root = root
self.url_base = "http+unix://{}/".format(quote_plus(sock))
Expand All @@ -41,13 +46,19 @@ def get(self, path, **args):
if args:
path += "?" + urlencode(args)
with requests_unixsocket.Session() as session:
return session.get(self.url_base + path, timeout=60)
return session.get(
self.url_base + path, timeout=self.default_timeout_seconds
)

def post(self, path, body, **args):
if args:
path += "?" + urlencode(args)
with requests_unixsocket.Session() as session:
return session.post(self.url_base + path, data=json.dumps(body), timeout=60)
return session.post(
self.url_base + path,
data=json.dumps(body),
timeout=self.default_timeout_seconds,
)

def configure_proxy(self, proxy):
log.debug("restarting snapd to pick up proxy config")
Expand Down

0 comments on commit 333e4d9

Please sign in to comment.