/ haystack / utils / asynchronous.py
asynchronous.py
 1  # SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
 2  #
 3  # SPDX-License-Identifier: Apache-2.0
 4  
 5  import inspect
 6  from collections.abc import Callable
 7  
 8  
 9  def is_callable_async_compatible(func: Callable) -> bool:
10      """
11      Returns if the given callable is usable inside a component's `run_async` method.
12  
13      :param func:
14          The callable to check.
15      :returns:
16          True if the callable is compatible, False otherwise.
17      """
18      return inspect.iscoroutinefunction(func)