Browse Source

Merge "Properly close streams"

tags/3.6.0
Zuul 5 months ago
parent
commit
cf2cfdda51
4 changed files with 10 additions and 0 deletions
  1. 1
    0
      tests/unit/test_streaming.py
  2. 2
    0
      zuul/executor/server.py
  3. 5
    0
      zuul/lib/log_streamer.py
  4. 2
    0
      zuul/web/__init__.py

+ 1
- 0
tests/unit/test_streaming.py View File

@@ -55,6 +55,7 @@ class WSClient(WebSocketBaseClient):
55 55
         self.send(json.dumps(req))
56 56
         self.event.set()
57 57
         super(WSClient, self).run()
58
+        self.close()
58 59
 
59 60
 
60 61
 class TestLogStreamer(tests.base.BaseTestCase):

+ 2
- 0
zuul/executor/server.py View File

@@ -141,6 +141,7 @@ class DiskAccountant(object):
141 141
                         .format(size=size, job=dirname, limit=self.limit))
142 142
                     self.usage_func(dirname, size)
143 143
             du.wait()
144
+            du.stdout.close()
144 145
             after = time.time()
145 146
             # Sleep half as long as that took, or 1s, whichever is longer
146 147
             delay_time = max((after - before) / 2, 1.0)
@@ -1891,6 +1892,7 @@ class AnsibleJob(object):
1891 1892
             self.log.debug("Stopped disk job killer")
1892 1893
 
1893 1894
         with self.proc_lock:
1895
+            self.proc.stdout.close()
1894 1896
             self.proc = None
1895 1897
 
1896 1898
         if timeout and watchdog.timed_out:

+ 5
- 0
zuul/lib/log_streamer.py View File

@@ -98,6 +98,11 @@ class RequestHandler(streamer_utils.BaseFingerRequestHandler):
98 98
                 if self.follow_log(log):
99 99
                     break
100 100
                 else:
101
+                    if log is not None:
102
+                        try:
103
+                            log.file.close()
104
+                        except Exception:
105
+                            pass
101 106
                     return
102 107
 
103 108
     def chunk_log(self, log_file):

+ 2
- 0
zuul/web/__init__.py View File

@@ -185,9 +185,11 @@ class LogStreamer(object):
185 185
                 if data:
186 186
                     self.websocket.send(data, False)
187 187
                 self.zuulweb.stream_manager.unregisterStreamer(self)
188
+                self.finger_socket.close()
188 189
                 return self.websocket.logClose(1000, "No more data")
189 190
         else:
190 191
             self.zuulweb.stream_manager.unregisterStreamer(self)
192
+            self.finger_socket.close()
191 193
             return self.websocket.logClose(1000, "Remote error")
192 194
 
193 195
 

Loading…
Cancel
Save