Allow most builds to be archived without writing a file to the disk.
This commit is contained in:
parent
ab35c864f8
commit
15a2f0d56f
1 changed files with 2 additions and 1 deletions
|
@ -12,6 +12,7 @@ from app import build_logs, log_archive
|
|||
from util.streamingjsonencoder import StreamingJSONEncoder
|
||||
|
||||
POLL_PERIOD_SECONDS = 30
|
||||
MEMORY_TEMPFILE_SIZE = 64 * 1024 # Large enough to handle approximately 99% of builds in memory
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
sched = BlockingScheduler()
|
||||
|
@ -32,7 +33,7 @@ def archive_redis_buildlogs():
|
|||
'logs': entries,
|
||||
}
|
||||
|
||||
with SpooledTemporaryFile() as tempfile:
|
||||
with SpooledTemporaryFile(MEMORY_TEMPFILE_SIZE) as tempfile:
|
||||
with GzipFile('testarchive', fileobj=tempfile) as zipstream:
|
||||
for chunk in StreamingJSONEncoder().iterencode(to_encode):
|
||||
zipstream.write(chunk)
|
||||
|
|
Reference in a new issue