|
同一进程里可以产生排它锁的异常吗? 产生两个不同的子进程然后分别访问文件能否造成排它锁的异常?
#!/usr/bin/env python
import os,sys,fcntl
file = '/home/kkang/file.lock'
lockfo = open ( file , 'a' )
fcntl.lockf( lockfo, fcntl.LOCK_EX | fcntl.LOCK_NB )
lockfo1 = open ( file , 'a' )
fcntl.lockf( lockfo1, fcntl.LOCK_EX | fcntl.LOCK_NB )
lockfo.write('lockfo write something\n')
lockfo1.write('another lockfo write something\n') |
|