From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class
Date: Wed, 8 Jul 2015 18:34:15 -0500 [thread overview]
Message-ID: <1436398461-26014-2-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1436398461-26014-1-git-send-email-anibal.limon@linux.intel.com>
FetchConnectionCache class acts as a container for socket connections
useful when implement connection cache into fetcher modules.
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
lib/bb/fetch2/__init__.py | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index cc772df..7fd9ec7 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1711,6 +1711,42 @@ class Fetch(object):
if ud.lockfile:
bb.utils.unlockfile(lf)
+class FetchConnectionCache(object):
+ """
+ A class which represents an container for socket connections.
+ """
+ def __init__(self):
+ self.cache = {}
+
+ def get_connection_name(self, host, port):
+ return host + ':' + str(port)
+
+ def add_connection(self, host, port, connection):
+ cn = self.get_connection_name(host, port)
+
+ if cn not in self.cache:
+ self.cache[cn] = connection
+
+ def get_connection(self, host, port):
+ connection = None
+
+ cn = self.get_connection_name(host, port)
+ if cn in self.cache:
+ connection = self.cache[cn]
+
+ return connection
+
+ def remove_connection(self, host, port):
+ cn = self.get_connection_name(host, port)
+ if cn in self.cache:
+ self.cache[cn].close()
+ del self.cache[cn]
+
+ def close_connections(self):
+ for cn in self.cache.keys():
+ self.cache[cn].close()
+ del self.cache[cn]
+
from . import cvs
from . import git
from . import gitsm
--
1.9.1
next prev parent reply other threads:[~2015-07-08 23:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
2015-07-08 23:34 ` Aníbal Limón [this message]
2015-07-08 23:34 ` [PATCHv4 2/7] fetch2: Add fetch parameter to checkstatus Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 3/7] fetch2/wget.py: Add support of connection cache in checkstatus Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 4/7] tests/fetch.py: Add FetchCheckStatusTest tests Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 5/7] fetch2/wget.py: checkstatus fix using proxy handler Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 6/7] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 7/7] fetch2/wget.py: checkstatus disable SSL cert validation Aníbal Limón
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436398461-26014-2-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox