From 8b52a31ed2c299b759f330c4f976b9c70f5765f4 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Wed, 24 Jun 2015 14:03:29 +0300 Subject: first version --- .../jsonrpclib-0.1.3/jsonrpclib/history.py | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/automation/trex_control_plane/python_lib/jsonrpclib-0.1.3/jsonrpclib/history.py (limited to 'scripts/automation/trex_control_plane/python_lib/jsonrpclib-0.1.3/jsonrpclib/history.py') diff --git a/scripts/automation/trex_control_plane/python_lib/jsonrpclib-0.1.3/jsonrpclib/history.py b/scripts/automation/trex_control_plane/python_lib/jsonrpclib-0.1.3/jsonrpclib/history.py new file mode 100755 index 00000000..d11863dc --- /dev/null +++ b/scripts/automation/trex_control_plane/python_lib/jsonrpclib-0.1.3/jsonrpclib/history.py @@ -0,0 +1,40 @@ +class History(object): + """ + This holds all the response and request objects for a + session. A server using this should call "clear" after + each request cycle in order to keep it from clogging + memory. + """ + requests = [] + responses = [] + _instance = None + + @classmethod + def instance(cls): + if not cls._instance: + cls._instance = cls() + return cls._instance + + def add_response(self, response_obj): + self.responses.append(response_obj) + + def add_request(self, request_obj): + self.requests.append(request_obj) + + @property + def request(self): + if len(self.requests) == 0: + return None + else: + return self.requests[-1] + + @property + def response(self): + if len(self.responses) == 0: + return None + else: + return self.responses[-1] + + def clear(self): + del self.requests[:] + del self.responses[:] -- cgit 1.2.3-korg