Not using async.Semaphore to aovid use nest-asyncio
(func)
| 233 | """Add restriction of maximum async calling times for a async func""" |
| 234 | |
| 235 | def final_decro(func): |
| 236 | """Not using async.Semaphore to aovid use nest-asyncio""" |
| 237 | __current_size = 0 |
| 238 | |
| 239 | @wraps(func) |
| 240 | async def wait_func(*args, **kwargs): |
| 241 | nonlocal __current_size |
| 242 | while __current_size >= max_size: |
| 243 | await asyncio.sleep(waitting_time) |
| 244 | __current_size += 1 |
| 245 | result = await func(*args, **kwargs) |
| 246 | __current_size -= 1 |
| 247 | return result |
| 248 | |
| 249 | return wait_func |
| 250 | |
| 251 | return final_decro |
| 252 |
nothing calls this directly
no test coverage detected