Pass an async func to thread target in Python?

I am trying to pass the some_callback function to a Thread as a target, however I get an error that it is never awaited. Is there a way to solve this problem?

The code I am using is the following:

async some_callback(args):
    await some_function()

_thread = threading.Thread(target=some_callback, args=("some text"))
_thread.start()

Yes, you can solve this problem by using the asyncio library instead of the threading library. Here’s an example:

import asyncio

async def some_callback(args):
    await some_function()

async def main():
    await asyncio.gather(some_callback("some text"))

asyncio.run(main())

In this example, we define an async function called some_callback that awaits some_function. We then define another async function called main that calls some_callback using asyncio.gather. Finally, we use asyncio.run to run the main function. This will allow some_callback to run asynchronously without the need for threads.