@@ -88,8 +88,10 @@ def _wait_for_task_completion(self, task_href: str) -> dict:
8888
8989 """
9090 result = self ._tasks_client .read (task_href )
91+ delay = 0.3
9192 while result .state not in ("failed" , "completed" ):
92- time .sleep (5 )
93+ time .sleep (delay )
94+ delay = min (delay * 2 , 5 )
9395 result = self ._tasks_client .read (task_href )
9496 if result .state == "failed" :
9597 raise TaskFailedError (f"task { task_href } has failed, " f"details: { result } " )
@@ -113,25 +115,24 @@ def _create_upload(self, file_path: str) -> (str, int):
113115 response = self ._uploads_client .create ({"size" : file_size })
114116 return response .pulp_href , file_size
115117
116- def _commit_upload (self , file_path : str , reference : str ) -> str :
118+ def _commit_upload (self , reference : str , file_sha256 : str ) -> str :
117119 """
118120 Commits upload and waits until upload will be transformed to artifact.
119121 Returns artifact reference upon completion.
120122
121123 Parameters
122124 ----------
123- file_path : str
124- Path to the file.
125125 reference : str
126126 Upload reference in Pulp.
127+ file_sha256 : str
128+ Pre-computed SHA256 of the file.
127129
128130 Returns
129131 -------
130132 str
131133 Reference to the created resource.
132134
133135 """
134- file_sha256 = hash_file (file_path , hash_type = "sha256" )
135136 response = self ._uploads_client .commit (reference , {"sha256" : file_sha256 })
136137 task_result = self ._wait_for_task_completion (response .task )
137138 return task_result .created_resources [0 ]
@@ -167,7 +168,7 @@ def _send_file(self, file_path: str) -> typing.Tuple[str, str]:
167168 self ._uploads_client .update (
168169 f"bytes 0-{ file_size - 1 } /{ file_size } " , reference , file_path
169170 )
170- artifact_href = self ._commit_upload (file_path , reference )
171+ artifact_href = self ._commit_upload (reference , file_sha256 )
171172 return file_sha256 , artifact_href
172173
173174 def check_if_artifact_exists (self , sha256 : str ) -> str :
0 commit comments