<@ULVA73B9P>, why would I use Async functions with...
# ask-marvin
j
@Marvin, why would I use Async functions with ConcurrentTaskRunner instead of using Sync functions? What's the differences?
m
The use of asynchronous functions with
ConcurrentTaskRunner
instead of synchronous functions offers several benefits: 1. Concurrency:
ConcurrentTaskRunner
can run tasks concurrently, allowing tasks to switch when blocking on I/O, which is common in asynchronous functions. Concurrency enables a system to do more than one thing simultaneously, but not necessarily at the same time, meaning execution of one task does not block the execution of other tasks in a flow. 2. Efficiency: Asynchronous functions are generally more efficient in I/O-bound and high-level structured network code. 3. Non-blocking Execution: In computing, concurrency refers to non-blocking execution within the restrictions of resources available and data dependencies between tasks. Choosing between synchronous and asynchronous functions depends on the type of tasks you are running within your flow. If your tasks are primarily I/O-bound and you wish to make efficient use of system resources by overlapping I/O with computation, asynchronous functions with
ConcurrentTaskRunner
would be a good choice. For more in-depth information, you can refer to these sources: - ConcurrentTaskRunner and concurrency vs parallelism - Second-generation workflow engine featuring "code as workflows" Using these concepts can vastly improve the developer experience and the performance of your workflows.
k
if your task function needs to
await
a coroutine, it's gonna have to be
async def
👀 1
j
I have all sync, but could convert to async if it means speed ups, didn't know if that made the tasks faster under Concurrent Task Runner
k
no, arbitrarily making tasks async won't change anything if they're not actually doing anything async
j
got it, that's what I assumed sadly 😞 thank u for clarification Kevin 🙏