import ast
src = '''
async def _handler(self, websocket):
    try:
        msg = await websocket.recv()
    except Exception:
        await websocket.send("error")
'''
tree = ast.parse(src)
handler = tree.body[0]
for node in ast.walk(handler):
    if isinstance(node, ast.Try) and node.handlers:
        handler_node = node.handlers[0]
        body = handler_node.body
        for stmt in body:
            for n in ast.walk(stmt):
                if isinstance(n, ast.Call):
                    f = n.func
                    attr = getattr(f, "attr", None) if hasattr(f, "attr") else "n/a"
                    print(f"func type: {type(f).__name__}, attr: {attr}")