Finally block of generator is not executed during garbage collection #828
In Python, when a generator object is garbage collected, its finally block will be executed and any print statement in it will be displayed on console.
Consider the python file
When it is executed in command line, the output will be:
Similar output is obtained when the code is defined in python 3 interactive shell:
The print statement in finally block is executed when the program ends/ the interactive shell exits.
However, when the same program is executed in voc, the finally block is not executed even though a
(the finalize method invokes next() on the generator to resume execution, so it should execute the print statement in the generator when garbage collector invokes the finalize method)
The text was updated successfully, but these errors were encountered: