launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25105
[Merge] ~pappacena/launchpad:tokens-outside-pool into launchpad:master
Thiago F. Pappacena has proposed merging ~pappacena/launchpad:tokens-outside-pool into launchpad:master.
Commit message:
Request snap proxy token outside the connection pool to avoid deadlocks
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/388492
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:tokens-outside-pool into launchpad:master.
diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
index c19e617..b21de87 100644
--- a/lib/lp/buildmaster/interactor.py
+++ b/lib/lp/buildmaster/interactor.py
@@ -135,6 +135,14 @@ class LimitedHTTPConnectionPool(HTTPConnectionPool):
# release it here then the next request may start using this
# connection's parser before this request has quite finished with
# it.
+ # XXX pappacena 2020-06-31: This may cause deadlocks in the
+ # event loop: something else in the event loop queue might be
+ # waiting to acquire the semaphore when no tokens are left before
+ # we have a chance to release a token.
+ # Please, note that calling release() right away is not a solution
+ # either, since Twisted returns the connection to the pool before
+ # the body was fetched, and this connection cannot be reused right
+ # away.
self._reactor.callLater(0, self._semaphore.release)
diff --git a/lib/lp/snappy/model/snapbuildbehaviour.py b/lib/lp/snappy/model/snapbuildbehaviour.py
index cbcba1d..5430833 100644
--- a/lib/lp/snappy/model/snapbuildbehaviour.py
+++ b/lib/lp/snappy/model/snapbuildbehaviour.py
@@ -104,8 +104,7 @@ class SnapProxyMixin:
response = yield treq.post(
url, headers={'Authorization': auth_header},
json={'username': proxy_username},
- reactor=self._slave.reactor,
- pool=self._slave.pool)
+ reactor=self._slave.reactor)
response = yield check_status(response)
token = yield treq.json_content(response)
defer.returnValue(token)