File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -139,23 +139,22 @@ def __init__(
139139 raise TypeError (
140140 f"Expected coroutine function, not { type (self .coro ).__name__ !r} ."
141141 )
142- if not isinstance (overlap , (bool , int )):
143- raise TypeError ("overlap must be a bool or a positive integer." )
144-
145142 if isinstance (overlap , bool ):
146- if overlap is True :
143+ if overlap :
147144 self ._run_with_semaphore = self ._run_direct
148- else :
145+ elif isinstance ( overlap , int ) :
149146 if overlap <= 1 :
150147 raise ValueError ("overlap as an integer must be greater than 1." )
151148 self ._semaphore = asyncio .Semaphore (overlap )
152- self ._run_with_semaphore = self ._make_semaphore_runner ()
149+ self ._run_with_semaphore = self ._semaphore_runner_factory ()
150+ else :
151+ raise TypeError ("overlap must be a bool or a positive integer." )
153152
154153 async def _run_direct (self , * args : Any , ** kwargs : Any ) -> None :
155154 """Run the coroutine directly."""
156155 await self .coro (* args , ** kwargs )
157156
158- def _make_semaphore_runner (self ) -> Callable [..., Awaitable [None ]]:
157+ def _semaphore_runner_factory (self ) -> Callable [..., Awaitable [None ]]:
159158 """Return a function that runs the coroutine with a semaphore."""
160159
161160 async def runner (* args : Any , ** kwargs : Any ) -> None :
You can’t perform that action at this time.
0 commit comments