Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
| 2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
| 3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
| 4 # | 4 # |
| 5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
| 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 8 # details. | 8 # details. |
| 9 # | 9 # |
| 10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 class RunProcess: | 205 class RunProcess: |
| 206 """ | 206 """ |
| 207 This is a helper class, used by slave commands to run programs in a child | 207 This is a helper class, used by slave commands to run programs in a child |
| 208 shell. | 208 shell. |
| 209 """ | 209 """ |
| 210 | 210 |
| 211 notreally = False | 211 notreally = False |
| 212 BACKUP_TIMEOUT = 5 | 212 BACKUP_TIMEOUT = 5 |
| 213 KILL = "KILL" | 213 KILL = "KILL" |
| 214 CHUNK_LIMIT = 128*1024 | 214 CHUNK_LIMIT = 128*1024 |
| 215 OUTPUT_LIMIT = 50*1024*1024 | |
|
cmp
2014/06/10 15:51:22
Add an inline comment ("Limit is 50 MB.")
Did you
| |
| 215 | 216 |
| 216 # Don't send any data until at least BUFFER_SIZE bytes have been collected | 217 # Don't send any data until at least BUFFER_SIZE bytes have been collected |
| 217 # or BUFFER_TIMEOUT elapsed | 218 # or BUFFER_TIMEOUT elapsed |
| 218 BUFFER_SIZE = 64*1024 | 219 BUFFER_SIZE = 64*1024 |
| 219 BUFFER_TIMEOUT = 5 | 220 BUFFER_TIMEOUT = 5 |
| 220 | 221 |
| 221 # For sending elapsed time: | 222 # For sending elapsed time: |
| 222 startTime = None | 223 startTime = None |
| 223 elapsedTime = None | 224 elapsedTime = None |
| 224 | 225 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 self.timeout = timeout | 316 self.timeout = timeout |
| 316 self.timer = None | 317 self.timer = None |
| 317 self.maxTime = maxTime | 318 self.maxTime = maxTime |
| 318 self.maxTimer = None | 319 self.maxTimer = None |
| 319 self.keepStdout = keepStdout | 320 self.keepStdout = keepStdout |
| 320 self.keepStderr = keepStderr | 321 self.keepStderr = keepStderr |
| 321 | 322 |
| 322 self.buffered = deque() | 323 self.buffered = deque() |
| 323 self.buflen = 0 | 324 self.buflen = 0 |
| 324 self.buftimer = None | 325 self.buftimer = None |
| 326 self.totalOutputLength = 0 | |
| 325 | 327 |
| 326 if usePTY == "slave-config": | 328 if usePTY == "slave-config": |
| 327 self.usePTY = self.builder.usePTY | 329 self.usePTY = self.builder.usePTY |
| 328 else: | 330 else: |
| 329 self.usePTY = usePTY | 331 self.usePTY = usePTY |
| 330 | 332 |
| 331 # usePTY=True is a convenience for cleaning up all children and | 333 # usePTY=True is a convenience for cleaning up all children and |
| 332 # grandchildren of a hung command. Fall back to usePTY=False on systems | 334 # grandchildren of a hung command. Fall back to usePTY=False on systems |
| 333 # and in situations where ptys cause problems. PTYs are posix-only, | 335 # and in situations where ptys cause problems. PTYs are posix-only, |
| 334 # and for .closeStdin to matter, we must use a pipe, not a PTY | 336 # and for .closeStdin to matter, we must use a pipe, not a PTY |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 | 616 |
| 615 def _addToBuffers(self, logname, data): | 617 def _addToBuffers(self, logname, data): |
| 616 """ | 618 """ |
| 617 Add data to the buffer for logname | 619 Add data to the buffer for logname |
| 618 Start a timer to send the buffers if BUFFER_TIMEOUT elapses. | 620 Start a timer to send the buffers if BUFFER_TIMEOUT elapses. |
| 619 If adding data causes the buffer size to grow beyond BUFFER_SIZE, then | 621 If adding data causes the buffer size to grow beyond BUFFER_SIZE, then |
| 620 the buffers will be sent. | 622 the buffers will be sent. |
| 621 """ | 623 """ |
| 622 n = len(data) | 624 n = len(data) |
| 623 | 625 |
| 626 self.totalOutputLength += n | |
| 627 if self.totalOutputLength > self.OUTPUT_LIMIT: | |
| 628 self.kill('output limit (%d) exceeded' % self.OUTPUT_LIMIT) | |
| 629 return | |
| 630 | |
| 624 self.buflen += n | 631 self.buflen += n |
| 625 self.buffered.append((logname, data)) | 632 self.buffered.append((logname, data)) |
| 626 if self.buflen > self.BUFFER_SIZE: | 633 if self.buflen > self.BUFFER_SIZE: |
| 627 self._sendBuffers() | 634 self._sendBuffers() |
| 628 elif not self.buftimer: | 635 elif not self.buftimer: |
| 629 self.buftimer = self._reactor.callLater(self.BUFFER_TIMEOUT, self._b ufferTimeout) | 636 self.buftimer = self._reactor.callLater(self.BUFFER_TIMEOUT, self._b ufferTimeout) |
| 630 | 637 |
| 631 def addStdout(self, data): | 638 def addStdout(self, data): |
| 632 if self.sendStdout: | 639 if self.sendStdout: |
| 633 self._addToBuffers('stdout', data) | 640 self._addToBuffers('stdout', data) |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 self.timer = None | 824 self.timer = None |
| 818 self.sendStatus({'header': "SIGKILL failed to kill process\n"}) | 825 self.sendStatus({'header': "SIGKILL failed to kill process\n"}) |
| 819 if self.sendRC: | 826 if self.sendRC: |
| 820 self.sendStatus({'header': "using fake rc=-1\n"}) | 827 self.sendStatus({'header': "using fake rc=-1\n"}) |
| 821 self.sendStatus({'rc': -1}) | 828 self.sendStatus({'rc': -1}) |
| 822 slave.reboot_tools.Reboot() | 829 slave.reboot_tools.Reboot() |
| 823 # In production, Reboot() does not return, and failed() is | 830 # In production, Reboot() does not return, and failed() is |
| 824 # never called. In testing mode, Reboot() returns immediately | 831 # never called. In testing mode, Reboot() returns immediately |
| 825 # with no effect, and we need to recover. | 832 # with no effect, and we need to recover. |
| 826 self.failed(RuntimeError("SIGKILL failed to kill process")) | 833 self.failed(RuntimeError("SIGKILL failed to kill process")) |
| OLD | NEW |