socket thread stores info if mongo error has happened during subprocess

This commit is contained in:
iLLiCiTiT 2019-10-25 18:24:36 +02:00
parent e0f7752205
commit 5d6f91d614

View file

@ -1,4 +1,5 @@
import os
import sys
import time
import signal
import socket
@ -23,6 +24,8 @@ class SocketThread(threading.Thread):
self._is_running = False
self.finished = False
self.mongo_error = False
def stop(self):
self._is_running = False
@ -97,6 +100,8 @@ class SocketThread(threading.Thread):
break
if data:
if data == b"MongoError":
self.mongo_error = True
connection.sendall(data)
except Exception as exc:
@ -110,4 +115,9 @@ class SocketThread(threading.Thread):
if self.subproc.poll() is None:
self.subproc.terminate()
lines = self.subproc.stdout.readlines()
if lines:
print("*** Socked Thread stdout ***")
for line in lines:
os.write(1, line)
self.finished = True