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

Git.execute output_stream is not documented to suppress kill_after_timeout, but does #1762

Open
@EliahKagan

Description

@EliahKagan

When callingGit.execute, including indirectly through the dynamic methods of aGit object, passing a non-None value ofoutput_stream suppresses the effect ofkill_after_timeout.Thethreading.Timer object is created with the localkill_process function as its callback, butstart is never called on it.

GitPython/git/cmd.py

Lines 1050 to 1079 ina58a6be

ifoutput_streamisNone:
ifkill_after_timeoutisnotNone:
watchdog.start()
stdout_value,stderr_value=proc.communicate()
ifkill_after_timeoutisnotNone:
watchdog.cancel()
ifkill_check.is_set():
stderr_value='Timeout: the command "%s" did not complete in %d '"secs."% (
" ".join(redacted_command),
kill_after_timeout,
)
ifnotuniversal_newlines:
stderr_value=stderr_value.encode(defenc)
# Strip trailing "\n".
ifstdout_value.endswith(newline)andstrip_newline_in_stdout:# type: ignore
stdout_value=stdout_value[:-1]
ifstderr_value.endswith(newline):# type: ignore
stderr_value=stderr_value[:-1]
status=proc.returncode
else:
max_chunk_size=max_chunk_sizeifmax_chunk_sizeandmax_chunk_size>0elseio.DEFAULT_BUFFER_SIZE
stream_copy(proc.stdout,output_stream,max_chunk_size)
stdout_value=proc.stdout.read()
stderr_value=proc.stderr.read()
# Strip trailing "\n".
ifstderr_value.endswith(newline):# type: ignore
stderr_value=stderr_value[:-1]
status=proc.wait()
# END stdout handling

This situation appears not entirely intentional, because:

So eitherkill_after_timeout should be honored even whenoutput_stream is used,or the docstring should be updated to mention that it does not (and the code possibly modified to not create theTimer object in the case that it is unused).

I am not sure which change should be made, so I'm opening this rather than a PR to propose one of them.

This is effectively separate from#1756. (One quality this shares with#1756 is that it is relevant only to the behavior ofGit.execute and functions that use it. Functions that usehandle_process_output are unaffected; itskill_after_timeout is implemented differently with nonequivalent behavior and separate code.handle_process_output also does not take anoutput_stream argument.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp