| 1 | ==== //depot/Demitech/BuildSlave/buildbot/slave/commands.py#2 (text) ==== |
|---|
| 2 | |
|---|
| 3 | @@ -211,7 +211,8 @@ |
|---|
| 4 | notreally = False |
|---|
| 5 | BACKUP_TIMEOUT = 5 |
|---|
| 6 | KILL = "KILL" |
|---|
| 7 | - |
|---|
| 8 | + CHUNK_LIMIT = 128*1024 |
|---|
| 9 | + |
|---|
| 10 | def __init__(self, builder, command, |
|---|
| 11 | workdir, environ=None, |
|---|
| 12 | sendStdout=True, sendStderr=True, sendRC=True, |
|---|
| 13 | @@ -284,6 +285,14 @@ |
|---|
| 14 | def sendStatus(self, status): |
|---|
| 15 | self.builder.sendUpdate(status) |
|---|
| 16 | |
|---|
| 17 | + # twisted current craps out if we stuff more than 640k of data through its serialization -- so |
|---|
| 18 | + # we have to chunk data up if we're reading it from potentially large stdio reads |
|---|
| 19 | + def _chunkForSend(self, data): |
|---|
| 20 | + while length(data) > ShellCommand.CHUNK_SIZE: |
|---|
| 21 | + yield data[:ShellCommand.CHUNK_SIZE] |
|---|
| 22 | + data = data[ShellCommand.CHUNK_SIZE:] |
|---|
| 23 | + yield data |
|---|
| 24 | + |
|---|
| 25 | def start(self): |
|---|
| 26 | # return a Deferred which fires (with the exit code) when the command |
|---|
| 27 | # completes |
|---|
| 28 | @@ -393,7 +402,8 @@ |
|---|
| 29 | |
|---|
| 30 | def addStdout(self, data): |
|---|
| 31 | if self.sendStdout: |
|---|
| 32 | - self.sendStatus({'stdout': data}) |
|---|
| 33 | + for chunk in self._chunkForSend(data): |
|---|
| 34 | + self.sendStatus({'stdout': chunk}) |
|---|
| 35 | if self.keepStdout: |
|---|
| 36 | self.stdout += data |
|---|
| 37 | if self.timer: |
|---|
| 38 | @@ -401,12 +411,14 @@ |
|---|
| 39 | |
|---|
| 40 | def addStderr(self, data): |
|---|
| 41 | if self.sendStderr: |
|---|
| 42 | - self.sendStatus({'stderr': data}) |
|---|
| 43 | + for chunk in self._chunkForSend(data): |
|---|
| 44 | + self.sendStatus({'stderr': chunk}) |
|---|
| 45 | if self.timer: |
|---|
| 46 | self.timer.reset(self.timeout) |
|---|
| 47 | |
|---|
| 48 | def addLogfile(self, name, data): |
|---|
| 49 | - self.sendStatus({'log': (name, data)}) |
|---|
| 50 | + for chunk in self._chunkForSend(data): |
|---|
| 51 | + self.sendStatus({'log': (name, chunk)}) |
|---|
| 52 | if self.timer: |
|---|
| 53 | self.timer.reset(self.timeout) |
|---|
| 54 | |
|---|