Python Forum
How to recognize, what functions are filled in of the Python interpreter stack?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to recognize, what functions are filled in of the Python interpreter stack?
#4
Thanks to all!
It turned out that the error was that the events were not reusable.
import asyncio, time

async def waiter(event, index_corrutine, start):
    print('start: ' + str(index_corrutine) + '\ttime=' + str(round(time.time()-start)))
    await event.wait()
    print('end: ' + str(index_corrutine) + '\ttime=' + str(round(time.time()-start)))

async def main():
    # Create an Event object.
    event = asyncio.Event()

    start = time.time()
    waiter_task1 = asyncio.create_task(waiter(event, 1, start))
    await asyncio.sleep(3)
    event.set()
    waiter_task2 = asyncio.create_task(waiter(event, 2, start))
    await asyncio.sleep(1)
    event.set()

    # Wait until the waiters of tasks is finished.
    await waiter_task1, waiter_task2

asyncio.run(main())
exit(1)
Output:
start: 1 time=0 end: 1 time=3 start: 2 time=3 end: 2 time=3
That is, after the event is set, it stops doing something, but does not throw an exception. Therefore, it seems that everything works correctly.
Reply


Messages In This Thread
RE: How to recognize, what functions are filled in of the Python interpreter stack? - by AlekseyPython - Mar-13-2019, 12:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python cant recognize PIP siubikYT 2 782 Jul-19-2023, 06:30 PM
Last Post: Lahearle
  Mac default python interpreter Viewpoint8455 2 939 Oct-13-2022, 06:25 AM
Last Post: perfringo
  Python Interpreter ankitdixit 4 2,719 Jun-10-2022, 12:37 PM
Last Post: katy1234
Photo Visual studio code unable to color syntax on python interpreter tomtom 4 6,953 Mar-02-2022, 01:23 AM
Last Post: tomtom
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,166 Feb-25-2022, 06:31 PM
Last Post: jao
  How to set Tab size to 4 in Python interpreter? zzzhhh 1 1,869 Jan-18-2022, 12:11 PM
Last Post: snippsat
  readline.parse_and_bind() does not work in start-up script of Python interpreter zzzhhh 0 1,540 Jan-18-2022, 11:05 AM
Last Post: zzzhhh
  Find last filled column in openpyxl Irv1n 2 12,867 Jan-16-2022, 11:05 AM
Last Post: Pedroski55
  Making a hotel filled with people categorizing them lucasrohr 3 1,481 Jan-09-2022, 05:13 PM
Last Post: lucasrohr
  My program won't recognize the filename. braingoblins 1 1,140 Jan-07-2022, 06:18 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020