Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run before_fn and after_fn for each generator iteration #7029

Merged
merged 9 commits into from Jan 22, 2024
5 changes: 5 additions & 0 deletions .changeset/big-bears-cover.md
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Run after_fn for async generators
4 changes: 2 additions & 2 deletions gradio/utils.py
Expand Up @@ -639,8 +639,8 @@ async def asyncgen_wrapper(*args, **kwargs):
before_fn(*before_args)
async for response in f(*args, **kwargs):
yield response
if after_fn:
after_fn(*after_args)
if after_fn:
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
after_fn(*after_args)

return asyncgen_wrapper

Expand Down