Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install portalocker

How to install portalocker

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install portalocker
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.3 Available View build log
0.3 Available View build log
Windows (64-bit)
0.3 Available View build log
0.3 Available View build log
Mac OS X (10.5+)
0.3 Available View build log
0.3 Available View build log
Linux (32-bit)
0.3 Available View build log
0.3 Available View build log
Linux (64-bit)
0.3 Available View build log
0.3 Available View build log
0.3 Available View build log
 
License
PSF
Imports
Lastest release
version 0.3 on Feb 24th, 2011

Overview

Portalocker is a library to provide an easy API to file locking.

Originally created as a Python Recipe by Jonathan Feinberg and Lowell Alleman http://code.activestate.com/recipes/65203-portalocker-cross-platform-posixnt-api-for-flock-s/

Examples

To make sure your cache generation scripts don't race, use the Lock class:

>>> import portalocker
>>> with portalocker.Lock('somefile', timeout=1) as fh:
    print >>fh, 'writing some stuff to my cache...'

To lock a file exclusively, use the lock method:

>>> import portalocker
>>> file = open('somefile', 'r+')
>>> portalocker.lock(file, portalocker.LOCK_EX)
>>> file.seek(12)
>>> file.write('foo')
>>> file.close()

There is no explicit need to unlock the file as it is automatically unlocked after file.close(). If you still feel the need to manually unlock a file than you can do it like this:

>>> portalocker.unlock(file)

Do note that your data might still be in a buffer so it is possible that your data is not available until you flush() or close().

Contact

The module is maintaned by Rick van Hattem <Rick.van.Hattem@Fawo.nl>. The project resides at https://github.com/WoLpH/portalocker . Bugs and feature requests can be submitted there. Patches are also very welcome.

Changelog

See CHANGELOG file

License

see the LICENSE file

Subscribe to package updates

Last updated Feb 24th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.