Skip to content

Commit

Permalink
Fix #458 (#459)
Browse files Browse the repository at this point in the history
* Fix #458

* Update README.md

* Update README.md
  • Loading branch information
Mogost authored May 20, 2024
1 parent c54db5c commit 12a68e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit 12a68e5

Please sign in to comment.