Package moul :: Package osdependent :: Module singleapp
[hide private]
[frames] | no frames]

Module singleapp



Simple single instance application

Includes portalocker code with minor tweaks for Python 2.4+ from Jonathan Feinberg <jdf@pobox.com> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203

Unit tests for lock/unlock are in tests/test_singleapp
>>> singleapp = SimpleSingleApp('testapp')
>>> lckfile = singleapp.lckfile
>>> if os.path.isfile(lckfile):
...     os.unlink(fpath)
>>> path, pid = singleapp.acquire()
>>> path == lckfile
True
>>> os.path.isfile(lckfile)
True
>>> singleapp.checkLocked()
2
>>> singleapp.release()
>>> os.path.isfile(lckfile)
False


Classes [hide private]
  SingleAppError
  SimpleSingleApp
A simple single instance application implemementation

Functions [hide private]
  lock(file, flags)
  unlock(file)

Variables [hide private]
  __author__ = 'Christian Heimes'
  __version__ = '$Id: singleapp.py 122 2007-02-02 17:34:06Z tiran $'
  __revision__ = '$Revision: 122 $'
  LOG = <logging.Logger instance at 0x4054b9cc>
  TEMPDIR = '/tmp'
  USER = 'heimes'
  PID = 5749
  LOCK_EX = 2
  LOCK_SH = 1
  LOCK_NB = 4
  LOCK = 6

Function Details [hide private]

lock(file, flags)

 
None

unlock(file)

 
None

Variables Details [hide private]

__author__

None
Value:
'Christian Heimes'                                                     
      

__version__

None
Value:
'$Id: singleapp.py 122 2007-02-02 17:34:06Z tiran $'                   
      

__revision__

None
Value:
'$Revision: 122 $'                                                     
      

LOG

None
Value:
<logging.Logger instance at 0x4054b9cc>                                
      

TEMPDIR

None
Value:
'/tmp'                                                                 
      

USER

None
Value:
'heimes'                                                               
      

PID

None
Value:
5749                                                                  
      

LOCK_EX

None
Value:
2                                                                     
      

LOCK_SH

None
Value:
1                                                                     
      

LOCK_NB

None
Value:
4                                                                     
      

LOCK

None
Value:
6