Skip to content

Commit cd3d049

Browse files
committed
Merge pull request #39 from ambitioninc/develop
Release 0.2.3
2 parents 60bf476 + 8401f19 commit cd3d049

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

db_mutex/db_mutex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from datetime import datetime, timedelta
1+
from datetime import timedelta
22
import functools
33
import logging
44

55
from django.conf import settings
66
from django.db import transaction, IntegrityError
7+
from django.utils import timezone
78

89
from .exceptions import DBMutexError, DBMutexTimeoutError
910
from .models import DBMutex
@@ -83,7 +84,7 @@ def delete_expired_locks(self):
8384
"""
8485
ttl_seconds = self.get_mutex_ttl_seconds()
8586
if ttl_seconds is not None:
86-
DBMutex.objects.filter(creation_time__lte=datetime.utcnow() - timedelta(seconds=ttl_seconds)).delete()
87+
DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()
8788

8889
def __call__(self, func):
8990
return self.decorate_callable(func)

db_mutex/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ class DBMutex(models.Model):
1313
"""
1414
lock_id = models.CharField(max_length=256, unique=True)
1515
creation_time = models.DateTimeField(auto_now_add=True)
16+
17+
class Meta:
18+
app_label = 'db_mutex'

db_mutex/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.2'
1+
__version__ = '0.2.3'

docs/installation.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
Installation
22
============
33

4-
To install the latest release, type::
5-
4+
* Install Django-db-mutex with your favorite Python package manager::
5+
6+
# Using pip
67
pip install django-db-mutex
8+
9+
# Or, using pip (from source, in editable form)
10+
pip install -e git://github.com/ambitioninc/django-db-mutex.git#egg=django-db-mutex
711

8-
To install the latest code directly from source, type::
12+
* Add ``'db_mutex'`` to your ``INSTALLED_APPS`` setting::
913

10-
pip install git+git://github.com/ambitioninc/django-db-mutex.git
14+
INSTALLED_APPS = (
15+
# other apps
16+
'db_mutex',
17+
)

run_tests.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
"""
2-
Provides the ability to run test on a standalone Django app.
3-
"""
41
import sys
52
from optparse import OptionParser
63

@@ -14,7 +11,7 @@
1411
django.setup()
1512

1613
# Django nose must be imported here since it depends on the settings being configured
17-
from django_nose import NoseTestSuiteRunner
14+
from django_nose import NoseTestSuiteRunner # noqa
1815

1916

2017
def run_tests(*test_args, **kwargs):

settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def configure_settings():
4949
'django_nose',
5050
),
5151
DEBUG=False,
52-
CACHES = {
52+
CACHES={
5353
'default': {
5454
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
5555
'LOCATION': 'unique-snowflake'

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
2-
import multiprocessing
3-
assert multiprocessing
41
import re
2+
import multiprocessing
53
from setuptools import setup, find_packages
64

75

6+
# import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
7+
assert multiprocessing
8+
9+
810
def get_version():
911
"""
1012
Extracts the version number from the version.py file.

0 commit comments

Comments
 (0)