[CRIU] [PATCH 2/2] p.haul: fix logging of exceptions in threads

Nikita Spiridonov nspiridonov at odin.com
Thu Oct 1 05:31:13 PDT 2015


Catch exceptions from threads and log them manually.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/images.py  |    9 ++++++---
 phaul/xem_rpc.py |    5 ++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/phaul/images.py b/phaul/images.py
index b9326ce..b5bd27c 100644
--- a/phaul/images.py
+++ b/phaul/images.py
@@ -39,9 +39,12 @@ class untar_thread(threading.Thread):
 		self.__dir = tdir
 
 	def run(self):
-		tf = tarfile.open(mode = "r|", fileobj = self.__sk.makefile())
-		tf.extractall(self.__dir)
-		tf.close()
+		try:
+			tf = tarfile.open(mode = "r|", fileobj = self.__sk.makefile())
+			tf.extractall(self.__dir)
+			tf.close()
+		except:
+			logging.exception("Exception in untar_thread")
 
 class img_tar:
 	def __init__(self, sk, dirname):
diff --git a/phaul/xem_rpc.py b/phaul/xem_rpc.py
index d320013..8139b80 100644
--- a/phaul/xem_rpc.py
+++ b/phaul/xem_rpc.py
@@ -190,7 +190,10 @@ class rpc_threaded_srv(threading.Thread):
 		self._stop_fd = None
 
 	def run(self):
-		self._mgr.loop(self._stop_fd)
+		try:
+			self._mgr.loop(self._stop_fd)
+		except:
+			logging.exception("Exception in rpc_threaded_srv")
 
 	def get_stop_fd(self):
 		sks = socket.socketpair()
-- 
1.7.1



More information about the CRIU mailing list