Thank you both for your replies. You are both quite correct and upon testing I get the desired results. I was mistakenly expecting the execution of the function to block at the fcntl.flock(f,fcntl.LOCK_EX) line. But I am slowly getting my head around it. Thanks