summaryrefslogtreecommitdiff
path: root/contrib/python/podman/libs/tunnel.py
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2018-06-20 19:14:27 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-22 17:25:44 +0000
commit2f0f9944b610773d2d547c59cc7d936665b2bbdc (patch)
treee30e0625d099bf0297ce70c88bf48e2955a13494 /contrib/python/podman/libs/tunnel.py
parent3092d2084761755776994a8febe2279d07e3d03b (diff)
downloadpodman-2f0f9944b610773d2d547c59cc7d936665b2bbdc.tar.gz
podman-2f0f9944b610773d2d547c59cc7d936665b2bbdc.tar.bz2
podman-2f0f9944b610773d2d547c59cc7d936665b2bbdc.zip
Add unittests and fix bugs
* Improved error messages * Improved checking of user input Signed-off-by: Jhon Honce <jhonce@redhat.com> Closes: #978 Approved by: mheon
Diffstat (limited to 'contrib/python/podman/libs/tunnel.py')
-rw-r--r--contrib/python/podman/libs/tunnel.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/contrib/python/podman/libs/tunnel.py b/contrib/python/podman/libs/tunnel.py
index 2cb178644..534326ff0 100644
--- a/contrib/python/podman/libs/tunnel.py
+++ b/contrib/python/podman/libs/tunnel.py
@@ -26,6 +26,7 @@ class Portal(collections.MutableMapping):
self.sweap = sweap
self.ttl = sweap * 2
self.lock = threading.RLock()
+ self._schedule_reaper()
def __getitem__(self, key):
"""Given uri return tunnel and update TTL."""
@@ -73,11 +74,12 @@ class Portal(collections.MutableMapping):
def reap(self):
"""Remove tunnels who's TTL has expired."""
+ now = time.time()
with self.lock:
- now = time.time()
- for entry, timeout in self.data:
- if timeout < now:
- self.__delitem__(entry)
+ reaped_data = self.data.copy()
+ for entry in reaped_data.items():
+ if entry[1][1] < now:
+ del self.data[entry[0]]
else:
# StopIteration as soon as possible
break
@@ -121,7 +123,6 @@ class Tunnel(object):
def close(self, id):
"""Close SSH tunnel."""
- print('Tunnel collapsed!')
if self._tunnel is None:
return