Add support of None argument in dp.throttled

This commit is contained in:
birdi 2019-08-03 15:27:20 +03:00
parent 828f6f2fbf
commit 769be286f7

View file

@ -1077,18 +1077,19 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
} }
) # update kwargs with parameters which were given to throttled ) # update kwargs with parameters which were given to throttled
if asyncio.iscoroutinefunction(on_throttled): if on_throttled:
await on_throttled(*args, **kwargs) if asyncio.iscoroutinefunction(on_throttled):
else: await on_throttled(*args, **kwargs)
kwargs.update( else:
{ kwargs.update(
'loop': asyncio.get_running_loop() {
} 'loop': asyncio.get_running_loop()
) }
partial_func = functools.partial(on_throttled, *args, **kwargs) )
asyncio.get_running_loop().run_in_executor(None, partial_func = functools.partial(on_throttled, *args, **kwargs)
partial_func asyncio.get_running_loop().run_in_executor(None,
) partial_func
)
return wrapped return wrapped