mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 01:54:53 +00:00
Add support of None argument in dp.throttled
This commit is contained in:
parent
828f6f2fbf
commit
769be286f7
1 changed files with 13 additions and 12 deletions
|
|
@ -1077,18 +1077,19 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
|
|||
}
|
||||
) # update kwargs with parameters which were given to throttled
|
||||
|
||||
if asyncio.iscoroutinefunction(on_throttled):
|
||||
await on_throttled(*args, **kwargs)
|
||||
else:
|
||||
kwargs.update(
|
||||
{
|
||||
'loop': asyncio.get_running_loop()
|
||||
}
|
||||
)
|
||||
partial_func = functools.partial(on_throttled, *args, **kwargs)
|
||||
asyncio.get_running_loop().run_in_executor(None,
|
||||
partial_func
|
||||
)
|
||||
if on_throttled:
|
||||
if asyncio.iscoroutinefunction(on_throttled):
|
||||
await on_throttled(*args, **kwargs)
|
||||
else:
|
||||
kwargs.update(
|
||||
{
|
||||
'loop': asyncio.get_running_loop()
|
||||
}
|
||||
)
|
||||
partial_func = functools.partial(on_throttled, *args, **kwargs)
|
||||
asyncio.get_running_loop().run_in_executor(None,
|
||||
partial_func
|
||||
)
|
||||
|
||||
return wrapped
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue