Skip to content
Discussion options

You must be logged in to vote

I see there 3 options:

  1. Handle exceptions inside func1 (func2)
async def func1(name: str):
    try:
        return {"message": f"Hello {name} form func1"}
    except:
        return {} # fallback value

...
  1. Add a decorator to wrap functions
def catch(func):
    async def wrapped(*args, **kwargs):
        try:
            return await func(*args, **kwargs)
        except:
            return None
    return wrapped

# apply decorator
@catch
def func1(...):
    ...
    
def func2(...):
    ...
    
@app.get("/test")
async def knowledge_panel(name_str: str):
    async with asyncer.create_task_group() as task_group:
        soon_value1 = task_group.soonify(func1)(name=name_str) # catch appl…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
4 participants
Converted from issue

This discussion was converted from issue #40 on September 23, 2025 14:53.