coro_thread_func

privex.helpers.asyncx.coro_thread_func(func: callable, *t_args, _output_queue: Optional[Union[queue.Queue, str]] = None, **t_kwargs)[source]

This function is not intended to be called directly. It’s designed to be used as the target of a threading.Thread.

Runs the coroutine function func using a new event loop for the thread this function is running within, and relays the result or an exception (if one was raised) via the queue.Queue _output_queue

See the higher level run_coro_thread() for more info.

Parameters
  • func (callable) – A reference to the async def coroutine function that you want to run

  • t_args – Positional arguments to pass-through to the coroutine function

  • _output_queue

    (default: None) The queue.Queue to emit the result or raised exception through. This can also be set to None to disable transmitting the result/exception via a queue.

    This can also be set to the string "default", which means the result/exception will be transmitted via the asyncx private queue _coro_thread_queue

  • t_kwargs – Keyword arguments to pass-through to the coroutine function