Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

squarecapadmin / Beaker   python

Repository URL to install this package:

Version: 1.6.4 

/ tests / test_synchronizer.py

from beaker.synchronization import *

# TODO: spawn threads, test locking.


def teardown():
    import shutil
    shutil.rmtree('./cache', True)

def test_reentrant_file():
    sync1 = file_synchronizer('test', lock_dir='./cache')
    sync2 = file_synchronizer('test', lock_dir='./cache')
    sync1.acquire_write_lock()
    sync2.acquire_write_lock()
    sync2.release_write_lock()
    sync1.release_write_lock()

def test_null():
    sync = null_synchronizer()
    assert sync.acquire_write_lock()
    sync.release_write_lock()

def test_mutex():
    sync = mutex_synchronizer('someident')
    sync.acquire_write_lock()
    sync.release_write_lock()