mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-22 04:25:55 -04:00
Fix bug in run_with_retries, better types
This commit is contained in:
parent
1d48e64853
commit
38eca67905
@ -3,7 +3,10 @@ Helpers for testing.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from typing import Any, Callable
|
from typing import Callable, TypeVar
|
||||||
|
|
||||||
|
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
class MockResponse:
|
class MockResponse:
|
||||||
@ -24,7 +27,7 @@ def retval(val):
|
|||||||
return lambda *args, **kwargs: val
|
return lambda *args, **kwargs: val
|
||||||
|
|
||||||
|
|
||||||
def run_with_retries(fn: Callable[..., Any]):
|
def run_with_retries(fn: Callable[..., T]) -> T:
|
||||||
"""
|
"""
|
||||||
Run the the given function repeatedly until it finishes without raising an
|
Run the the given function repeatedly until it finishes without raising an
|
||||||
AssertionError. Sleep a bit between attempts. If the function doesn't
|
AssertionError. Sleep a bit between attempts. If the function doesn't
|
||||||
@ -41,4 +44,4 @@ def run_with_retries(fn: Callable[..., Any]):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
fn()
|
return fn()
|
||||||
|
Loading…
Reference in New Issue
Block a user