Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #458 #459

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion post_office/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import tempfile
import time

from post_office.settings import get_lock_file_name


class FileLocked(Exception):
pass
Expand Down Expand Up @@ -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())
4 changes: 4 additions & 0 deletions post_office/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading