The fnctl.flock call does not use LOCK_NB, so if it fails with an OSError, that is Really Bad™ and can't be handled cleanly.