File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ tests_src = tests
66docs_src = docs/src
77all_src = $(pkg_src ) $(tests_src )
88
9- isort = isort -rc $(all_src )
9+ isort = isort $(all_src )
1010autoflake = autoflake -r --remove-all-unused-imports --ignore-init-module-imports $(all_src )
1111black = black $(all_src )
1212flake8 = flake8 $(all_src )
Original file line number Diff line number Diff line change 1515def repeat_every (
1616 * ,
1717 seconds : float ,
18- wait_first : bool = False ,
18+ wait_first : float = None ,
1919 logger : Optional [logging .Logger ] = None ,
2020 raise_exceptions : bool = False ,
2121 max_repetitions : Optional [int ] = None ,
@@ -30,8 +30,8 @@ def repeat_every(
3030 ----------
3131 seconds: float
3232 The number of seconds to wait between repeated calls
33- wait_first: bool (default False )
34- If True , the function will wait for a single period before the first call
33+ wait_first: float (default None )
34+ If not None , the function will wait for the given duration before the first call
3535 logger: Optional[logging.Logger] (default None)
3636 The logger to use to log any exceptions raised by calls to the decorated function.
3737 If not provided, exceptions will not be logged by this function (though they may be handled by the event loop).
@@ -56,8 +56,8 @@ async def wrapped() -> None:
5656
5757 async def loop () -> None :
5858 nonlocal repetitions
59- if wait_first :
60- await asyncio .sleep (seconds )
59+ if wait_first is not None :
60+ await asyncio .sleep (wait_first )
6161 while max_repetitions is None or repetitions < max_repetitions :
6262 try :
6363 if is_coroutine :
Original file line number Diff line number Diff line change @@ -44,10 +44,9 @@ check_for_python3
4444check_for_poetry
4545
4646set -x
47- poetry run pip install -r requirements.txt
4847poetry install
4948
5049{ set +x; } 2> /dev/null
5150echo " "
52- echo " Virtual environment interpreter installed at :"
53- poetry run python -c " import sys; print(sys.executable) "
51+ echo " Virtual environment interpreter details :"
52+ poetry env info
Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ def repeatedly_print_hello() -> None:
5050
5151@pytest .mark .asyncio
5252async def test_repeat_print_wait (capsys : CaptureFixture ) -> None :
53- @repeat_every (seconds = 0.07 , max_repetitions = 3 , wait_first = True )
54- def repeatedly_print_hello () -> None :
53+ @repeat_every (seconds = 0.07 , max_repetitions = 3 , wait_first = 0.1 )
54+ async def repeatedly_print_hello () -> None :
5555 print ("hello" )
5656
5757 await repeatedly_print_hello ()
58- await asyncio .sleep (0.1 )
58+ await asyncio .sleep (0.15 )
5959 out , err = capsys .readouterr ()
6060 assert out == "hello\n " * 1
6161 assert err == ""
You can’t perform that action at this time.
0 commit comments