Skip to content

Commit 1d26515

Browse files
committed
allow for timeout propagation
1 parent aafb300 commit 1d26515

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

git/remote.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,8 @@ def update(self, **kwargs: Any) -> 'Remote':
707707
return self
708708

709709
def _get_fetch_info_from_stderr(self, proc: 'Git.AutoInterrupt',
710-
progress: Union[Callable[..., Any], RemoteProgress, None]
710+
progress: Union[Callable[..., Any], RemoteProgress, None],
711+
timeout: float = 60.0
711712
) -> IterableList['FetchInfo']:
712713

713714
progress = to_progress_instance(progress)
@@ -724,7 +725,8 @@ def _get_fetch_info_from_stderr(self, proc: 'Git.AutoInterrupt',
724725
cmds = set(FetchInfo._flag_map.keys())
725726

726727
progress_handler = progress.new_message_handler()
727-
handle_process_output(proc, None, progress_handler, finalizer=None, decode_streams=False)
728+
handle_process_output(proc, None, progress_handler, finalizer=None, decode_streams=False,
729+
timeout=timeout)
728730

729731
stderr_text = progress.error_lines and '\n'.join(progress.error_lines) or ''
730732
proc.wait(stderr=stderr_text)
@@ -769,7 +771,8 @@ def _get_fetch_info_from_stderr(self, proc: 'Git.AutoInterrupt',
769771
return output
770772

771773
def _get_push_info(self, proc: 'Git.AutoInterrupt',
772-
progress: Union[Callable[..., Any], RemoteProgress, None]) -> IterableList[PushInfo]:
774+
progress: Union[Callable[..., Any], RemoteProgress, None],
775+
timeout: float = 60.0) -> IterableList[PushInfo]:
773776
progress = to_progress_instance(progress)
774777

775778
# read progress information from stderr
@@ -786,7 +789,8 @@ def stdout_handler(line: str) -> None:
786789
# If an error happens, additional info is given which we parse below.
787790
pass
788791

789-
handle_process_output(proc, stdout_handler, progress_handler, finalizer=None, decode_streams=False)
792+
handle_process_output(proc, stdout_handler, progress_handler, finalizer=None, decode_streams=False,
793+
timeout=timeout)
790794
stderr_text = progress.error_lines and '\n'.join(progress.error_lines) or ''
791795
try:
792796
proc.wait(stderr=stderr_text)
@@ -813,7 +817,8 @@ def _assert_refspec(self) -> None:
813817

814818
def fetch(self, refspec: Union[str, List[str], None] = None,
815819
progress: Union[RemoteProgress, None, 'UpdateProgress'] = None,
816-
verbose: bool = True, **kwargs: Any) -> IterableList[FetchInfo]:
820+
verbose: bool = True, timeout: float = 60.0,
821+
**kwargs: Any) -> IterableList[FetchInfo]:
817822
"""Fetch the latest changes for this remote
818823
819824
:param refspec:
@@ -853,13 +858,14 @@ def fetch(self, refspec: Union[str, List[str], None] = None,
853858

854859
proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False,
855860
universal_newlines=True, v=verbose, **kwargs)
856-
res = self._get_fetch_info_from_stderr(proc, progress)
861+
res = self._get_fetch_info_from_stderr(proc, progress, timeout=timeout)
857862
if hasattr(self.repo.odb, 'update_cache'):
858863
self.repo.odb.update_cache()
859864
return res
860865

861866
def pull(self, refspec: Union[str, List[str], None] = None,
862867
progress: Union[RemoteProgress, 'UpdateProgress', None] = None,
868+
timeout: float = 60.0,
863869
**kwargs: Any) -> IterableList[FetchInfo]:
864870
"""Pull changes from the given branch, being the same as a fetch followed
865871
by a merge of branch with your local branch.
@@ -874,14 +880,14 @@ def pull(self, refspec: Union[str, List[str], None] = None,
874880
kwargs = add_progress(kwargs, self.repo.git, progress)
875881
proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True,
876882
universal_newlines=True, v=True, **kwargs)
877-
res = self._get_fetch_info_from_stderr(proc, progress)
883+
res = self._get_fetch_info_from_stderr(proc, progress, timeout=timeout)
878884
if hasattr(self.repo.odb, 'update_cache'):
879885
self.repo.odb.update_cache()
880886
return res
881887

882888
def push(self, refspec: Union[str, List[str], None] = None,
883889
progress: Union[RemoteProgress, 'UpdateProgress', Callable[..., RemoteProgress], None] = None,
884-
**kwargs: Any) -> IterableList[PushInfo]:
890+
timeout: float = 60.0, **kwargs: Any) -> IterableList[PushInfo]:
885891
"""Push changes from source branch in refspec to target branch in refspec.
886892
887893
:param refspec: see 'fetch' method
@@ -909,7 +915,7 @@ def push(self, refspec: Union[str, List[str], None] = None,
909915
kwargs = add_progress(kwargs, self.repo.git, progress)
910916
proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True,
911917
universal_newlines=True, **kwargs)
912-
return self._get_push_info(proc, progress)
918+
return self._get_push_info(proc, progress, timeout=timeout)
913919

914920
@ property
915921
def config_reader(self) -> SectionConstraint[GitConfigParser]:

0 commit comments

Comments
 (0)