import os, imp pid = os.fork() if pid != 0: print "In the parent" else: print "In the child" if __name__ != "__main__": assert imp.lock_held() print "Import lock held: ", imp.lock_held() print "Done\n"