[Python] How do I pass an async function to a thread target in Python?

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code:

    async some_callback(args):
    await some_function()


    and I need to give it to a Thread as a target:

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


    The error that I get is "some_callback is never awaited".
    Any ideas how can I solve this problem?

    Continue reading...

Compartilhe esta Página