Lifetime of a local reference

Marko Rauhamaa marko at pacujo.net
Tue Feb 26 16:54:00 EST 2019


Consider this function:

    def fun():
        f = open("lock")
        flock.flock(f, fcntl.LOCK_EX)
        do_stuff()
        sys.exit(0)

Question: can a compliant Python implementation close f (and,
consequently, release the file lock) before/while do_stuff() is
executed?

I couldn't find an immediate answer in the documentation.


Marko


More information about the Python-list mailing list