Python Forum

Full Version: How to recognize, what functions are filled in of the Python interpreter stack?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Python 3.7.2

I wrote a program using the asyncio library. If I run it, then after a short time I get the error "maximum recursion depth exceeded while calling a Python object". In the code, I never use recursion anywhere, so I want to know the names of the functions that occupied the entire of Python's stack.

How to do it?
Currently I try to debug my own program. I use for this pudb, which is a curses version of pdb.
https://pypi.org/project/pudb/

Instead of continue, you can step in and watch what happens on the stack and what is called.
Here a screencast

It's nice to see, that the German Python community has also cool projects online.
Thank you!
But my program consists of about two hundred files and the error does not appear immediately. I think it is almost impossible to trace this error with the help of such a simplified tool.
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.