[Python] Python asyncio wait and notify

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to do something similar like C# ManualResetEvent but in Python.

    I have attempted to do it in python but doesn't seem to work.

    import asyncio

    cond = asyncio.Condition()

    async def main():
    some_method()

    cond.notify()

    async def some_method():
    print("Starting...")

    await cond.acquire()
    await cond.wait()
    cond.release()

    print("Finshed...")

    main()


    I want the some_method to start then wait until signaled to start again.

    Continue reading...

Compartilhe esta Página