asyncio
library to make it easier to write asynchronous code using the async/await
syntax. This onboarding guide will help you understand the basics of asynchronous programming in Python and how to use it in your Chainlit project.
async
and await
keywords are used to define and work with asynchronous code in Python. An async
function is a coroutine, which is a special type of function that can pause its execution and resume later, allowing other tasks to run in the meantime.
To define an async function, use the async def
syntax:
await
keyword:
make_async
function provided by the Chainlit library to transform a synchronous function into an asynchronous one:
run_sync
function provided by the Chainlit library: