Watch out for this common generator pitfall.
What happens to a try/finally, with block, or async with block inside a generator if the generator isn't exhausted? Does the cleanup code still run? When and how does it run? In this video we take a look at the answers to these questions and learn how to avoid a common situation where cleanup code doesn't run when you want it to.
― mCoding with James Murphy (https://mcoding.io)
PEP 533: https://peps.python.org/pep-0533/
Discussion on GH issue: https://github.com/python/cpython/iss...
Source code: https://github.com/mCodingLLC/VideosS...
SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!
/ mcoding
Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
https://www.paypal.com/donate/?hosted...
Want to donate crypto? Check out the rest of my supported donations on my website!
https://mcoding.io/donate
Top patrons and donors: Laura M, Neel R, Dragos C, Jameson, Matt R, Pi, Vahnekie, Johan A, Mark M, Mutual Information
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: / discord
Github: https://github.com/mCodingLLC/
Reddit: / mcoding
Facebook: / james.mcoding
CHAPTERS
---------------------------------------------------
0:00 Intro
1:21 The cleanup question
5:30 The async case
Watch video Watch out for this (async) generator cleanup pitfall in Python online without registration, duration hours minute second in high quality. This video was added by user mCoding 20 September 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 21,443 once and liked it 1.1 thousand people.