diff --git a/README.md b/README.md index 350463f1..c963cd7e 100644 --- a/README.md +++ b/README.md @@ -452,6 +452,17 @@ POST_OFFICE = { } ``` +### Lock File Name +The default lock file name is `post_office`, but this can be altered by setting `LOCK_FILE_NAME` in the configuration. + +```python +# Put this in settings.py +POST_OFFICE = { + ... + 'LOCK_FILE_NAME': 'custom_lock_file', +} +``` + ### Override Recipients Defaults to `None`. This option is useful if you want to redirect all diff --git a/post_office/lockfile.py b/post_office/lockfile.py index ec95baee..1340785e 100644 --- a/post_office/lockfile.py +++ b/post_office/lockfile.py @@ -23,6 +23,8 @@ import tempfile import time +from post_office.settings import get_lock_file_name + class FileLocked(Exception): pass @@ -152,4 +154,4 @@ def __exit__(self, type, value, traceback): self.release() -default_lockfile = os.path.join(tempfile.gettempdir(), 'post_office') +default_lockfile = os.path.join(tempfile.gettempdir(), get_lock_file_name()) diff --git a/post_office/settings.py b/post_office/settings.py index 387d31db..19aa7617 100644 --- a/post_office/settings.py +++ b/post_office/settings.py @@ -83,6 +83,10 @@ def get_celery_enabled(): return get_config().get('CELERY_ENABLED', False) +def get_lock_file_name(): + return get_config().get('LOCK_FILE_NAME', 'post_office') + + def get_threads_per_process(): return get_config().get('THREADS_PER_PROCESS', 5)