36
36
unicodify ,
37
37
)
38
38
from pathvalidate import sanitize_filename
39
- from requests .exceptions import (
40
- HTTPError ,
41
- RequestException ,
42
- )
39
+ from requests .exceptions import HTTPError
43
40
44
- from planemo .galaxy .api import summarize_history
41
+ from planemo .galaxy .api import (
42
+ retry_on_timeouts ,
43
+ summarize_history ,
44
+ )
45
45
from planemo .io import wait_on
46
46
from planemo .runnable import (
47
47
ErrorRunResponse ,
@@ -811,30 +811,11 @@ def wait_for_invocation_and_jobs(
811
811
812
812
def _wait_for_invocation (ctx , gi , invocation_id , polling_backoff = 0 ):
813
813
def state_func ():
814
- return _retry_on_timeouts (ctx , gi , lambda gi : gi .invocations .show_invocation (invocation_id ))
814
+ return retry_on_timeouts (ctx , gi , lambda gi : gi .invocations .show_invocation (invocation_id ))
815
815
816
816
return _wait_on_state (state_func , polling_backoff )
817
817
818
818
819
- def _retry_on_timeouts (ctx , gi , f ):
820
- gi .timeout = 60
821
- try_count = 5
822
- try :
823
- for try_num in range (try_count ):
824
- start_time = time .time ()
825
- try :
826
- return f (gi )
827
- except RequestException :
828
- end_time = time .time ()
829
- if end_time - start_time > 45 and (try_num + 1 ) < try_count :
830
- ctx .vlog ("Galaxy seems to have timed out, retrying to fetch status." )
831
- continue
832
- else :
833
- raise
834
- finally :
835
- gi .timeout = None
836
-
837
-
838
819
def has_jobs_in_states (ctx , gi , history_id , states ):
839
820
params = {"history_id" : history_id }
840
821
jobs_url = gi .url + "/jobs"
@@ -849,7 +830,7 @@ def _wait_for_history(ctx, gi, history_id, polling_backoff=0):
849
830
# no need to wait for active jobs anymore I think.
850
831
851
832
def state_func ():
852
- return _retry_on_timeouts (ctx , gi , lambda gi : gi .histories .show_history (history_id ))
833
+ return retry_on_timeouts (ctx , gi , lambda gi : gi .histories .show_history (history_id ))
853
834
854
835
return _wait_on_state (state_func , polling_backoff )
855
836
@@ -862,7 +843,7 @@ def _wait_for_invocation_jobs(ctx, gi, invocation_id, polling_backoff=0):
862
843
ctx .log (f"waiting for invocation { invocation_id } " )
863
844
864
845
def state_func ():
865
- return _retry_on_timeouts (ctx , gi , lambda gi : gi .jobs .get_jobs (invocation_id = invocation_id ))
846
+ return retry_on_timeouts (ctx , gi , lambda gi : gi .jobs .get_jobs (invocation_id = invocation_id ))
866
847
867
848
return _wait_on_state (state_func , polling_backoff )
868
849
0 commit comments