- Timestamp:
- Dec 12, 2019, 12:43:45 PM (15 months ago)
- Branches:
- asyncio, master, proxy-ticket
- Children:
- b1261cb
- Parents:
- c7f83a3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mgstest/http.py
rc7f83a3 r4459cdd 19 19 import socket 20 20 import subprocess 21 import sys 21 22 22 23 from http.client import HTTPConnection … … 52 53 # output filter thread 53 54 self._fthread = None 55 # Error stream handler thread. This is needed to synchronize 56 # output between Python and the subprocess. 57 self._ethread = None 54 58 55 59 def connect(self): … … 61 65 if self._output_filter: 62 66 self._sproc = subprocess.Popen(self.command, stdout=subprocess.PIPE, 67 stderr=subprocess.PIPE, 63 68 stdin=s_remote, close_fds=True, 64 69 bufsize=0) … … 68 73 else: 69 74 self._sproc = subprocess.Popen(self.command, stdout=s_remote, 75 stderr=subprocess.PIPE, 70 76 stdin=s_remote, close_fds=True, 71 77 bufsize=0) 78 self._ethread = Thread(target=_stderr_writer, 79 args=(self._sproc.stderr,)) 80 self._ethread.start() 72 81 self.sock = s_local 73 82 … … 94 103 if self._fthread: 95 104 self._fthread.join() 105 if self._ethread: 106 self._ethread.join() 96 107 97 108 # close the connection in the super class, which also calls 98 109 # self.sock.close() 99 110 super().close() 111 112 113 114 def _stderr_writer(stream): 115 """Flush incoming data to sys.stderr. 116 117 This is a workaround to prevent output from gnutls-cli and the 118 Python interpreter overwriting each other in the test 119 logs. Forcing gnutls-cli stderr through Python ensures 120 synchronization (via global interpreter lock). 121 """ 122 for line in stream: 123 print(line.decode(), file=sys.stderr, end='', flush=True)
Note: See TracChangeset
for help on using the changeset viewer.