Skip to content

[Question]: HELP! Trio was expecting an async function, but instead it got a coroutine object #5651

Closed
@anthonya0713

Description

@anthonya0713

Describe your problem

  • Exception Group Traceback (most recent call last):
    | File "/ragflow/rag/svr/task_executor.py", line 618, in handle_task
    | await do_handle_task(task)
    | File "/ragflow/rag/svr/task_executor.py", line 536, in do_handle_task
    | await with_res()
    | File "/ragflow/graphrag/general/index.py", line 115, in call
    | reso = await er(self.graph)
    | File "/ragflow/graphrag/entity_resolution.py", line 98, in call
    | async with trio.open_nursery() as nursery:
    | File "/ragflow/.venv/lib/python3.10/site-packages/trio/_core/_run.py", line 1058, in aexit
    | raise combined_error_from_nursery
    | exceptiongroup.ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/ragflow/graphrag/entity_resolution.py", line 102, in call
    | nursery.start_soon(self._resolve_candidate(candidate_resolution_i, resolution_result))
    | File "/ragflow/.venv/lib/python3.10/site-packages/trio/_core/_run.py", line 1302, in start_soon
    | GLOBAL_RUN_CONTEXT.runner.spawn_impl(async_fn, args, self, name)
    | File "/ragflow/.venv/lib/python3.10/site-packages/trio/_core/_run.py", line 1870, in spawn_impl
    | coro = context.run(coroutine_or_error, async_fn, *args) # type: ignore[arg-type]
    | File "/ragflow/.venv/lib/python3.10/site-packages/trio/_util.py", line 88, in coroutine_or_error
    | raise TypeError(
    | TypeError: Trio was expecting an async function, but instead it got a coroutine object <coroutine object EntityResolution._resolve_candidate at 0x7f0c681e3d10>
    |
    | Probably you did something like:
    |
    | trio.run(_resolve_candidate(...)) # incorrect!
    | nursery.start_soon(_resolve_candidate(...)) # incorrect!
    |
    | Instead, you want (notice the parentheses!):
    |
    | trio.run(_resolve_candidate, ...) # correct!
    | nursery.start_soon(_resolve_candidate, ...) # correct!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions