Re: Await expressions

Liste des GroupesRevenir à cl python 
Sujet : Re: Await expressions
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 01. Feb 2024, 18:32:58
Autres entêtes
Organisation : Stefan Ram
Message-ID : <future-20240201182111@ram.dialup.fu-berlin.de>
References : 1 2 3
ram@zedat.fu-berlin.de (Stefan Ram) writes:
(Then, it should also be interesting to understand how asyncio
uses "await" to implement asynchronous I/O.)

  I have taken "sleep" from asyncio\tasks.py and simplified it a bit:

async def sleep( delay, result=None, *, loop=None ):

    loop = events.get_running_loop()

    future = loop.create_future()

    h = loop.call_later
    ( delay, futures._set_result_unless_cancelled, future, result )
   
    try: return await future
    finally: h.cancel()

  So, this is how the control is transferred to the event
  loop after an "await sleep"! Initially, the control goes
  to "sleep", but this transfers the control to the event loop
  (until "sleep" stops waiting for its future in "await future").


Date Sujet#  Auteur
26 Jan 24 * Await expressions9Stefan Ram
26 Jan 24 +* Re: Await expressions (Posting On Python-List Prohibited)3Stefan Ram
28 Jan 24 i`* Re: Await expressions2Stefan Ram
29 Jan 24 i `- Re: Await expressions1Stefan Ram
31 Jan 24 +- Re: Await expressions1Stefan Ram
1 Feb 24 `* Re: Await expressions4Stefan Ram
1 Feb 24  `* Re: Await expressions3Stefan Ram
1 Feb 24   `* Re: Await expressions2Stefan Ram
2 Feb 24    `- Re: Await expressions1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal