Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions fire/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,22 @@ def _CallAndUpdateTrace(component, args, component_trace, treatment='class',
(varargs, kwargs), consumed_args, remaining_args, capacity = parse(args)

# Call the function.
if inspectutils.IsCoroutineFunction(fn):
try:
loop = asyncio.get_running_loop()
except RuntimeError:
# No event loop running, create a new one
component = asyncio.run(fn(*varargs, **kwargs))
try:
if inspectutils.IsCoroutineFunction(fn):
try:
loop = asyncio.get_running_loop()
except RuntimeError:
# No event loop running, create a new one
component = asyncio.run(fn(*varargs, **kwargs))
else:
# Event loop is already running
component = loop.run_until_complete(fn(*varargs, **kwargs))
else:
# Event loop is already running
component = loop.run_until_complete(fn(*varargs, **kwargs))
else:
component = fn(*varargs, **kwargs)
component = fn(*varargs, **kwargs)
except TypeError as e:
if 'required' in str(e) or 'missing' in str(e) or 'argument' in str(e):
raise FireError(str(e)) from None
raise

if treatment == 'class':
action = trace.INSTANTIATED_CLASS
Expand Down