FDs will be closed after exception automatically in python2.7?
D'Arcy Cain <darcy at VybeNetworks.com> writes:
> On 2019-06-10 10:48, Michael Torrie wrote:
> > fd = open("file","w+")
> > with fd:
> There is still a small window there if there are asynchronous events
> happening. Use this instead:
> with open("file","w+") as fd:
That makes the window smaller, but it doesn't actually eliminate it. Look
at the generated byte code. In both cases the call to open() is over and
the open file is created _before_ the SETUP_WITH instruction is executed.