Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

job.trace(iterator=True) is not safe for.decode() / per-line processing#3200

Unanswered
stdedos asked this question inQ&A
Discussion options

According tohttps://python-gitlab.readthedocs.io/en/stable/gl_objects/pipelines_and_jobs.html#id6, the result of.trace(streamed=False) is/are "entirely stored in memory in this example".

I believe similar behavior can be achieved viaiterator=True, though without callbacks.

The function

defresponse_content(
response:requests.Response,
streamed:bool,
action:Callable[[bytes],Any]|None,
chunk_size:int,
*,
iterator:bool,
)->bytes|Iterator[Any]|None:
ifiterator:
returnresponse.iter_content(chunk_size=chunk_size)
ifstreamedisFalse:
returnresponse.content
ifactionisNone:
action=_StdoutStream()
forchunkinresponse.iter_content(chunk_size=chunk_size):
ifchunk:
action(chunk)
returnNone

even though it usesresponse.iter_content, whichcould supportdecode_unicode=True (def iter_content(self, chunk_size=1, decode_unicode=False):), but there is currently no way to pass that downward.

The result is a binary stream, which is unworkableas-is for line-based operations - as I "expect"/process the Job Log as a line stream (e.g. match this, ignore that ...). This also mirrors "average Joe's processing" of a job log: Go through it line-by-line, search etc


Not a blocker - just wondering if there is a more elegant, in-library workaround (or solution I have missed).

... or "food for thought" if development is due to happen.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@stdedos

[8]ページ先頭

©2009-2025 Movatter.jp