def setUp(self):
super(Base, self).setUp()
self.lines = []
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind(("127.0.0.1", 0))
self.t = threading.Thread(target=self.readlog)
self.t.daemon = True
self.t.start()
examplepy = os.path.join(os.path.dirname(__file__),
"examples.py")
if os.name == 'posix':
kwargs = {
'preexec_fn': os.setsid
}
else:
kwargs = {
'creationflags': subprocess.CREATE_NEW_PROCESS_GROUP
}
self.subp = subprocess.Popen(['python', examplepy, self.name,
str(self.sock.getsockname()[1])],
**kwargs)
评论列表
文章目录