File tree Expand file tree Collapse file tree 7 files changed +25
-15
lines changed Expand file tree Collapse file tree 7 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 1
- from datetime import datetime , timedelta
1
+ from datetime import timedelta
2
2
import functools
3
3
import logging
4
4
5
5
from django .conf import settings
6
6
from django .db import transaction , IntegrityError
7
+ from django .utils import timezone
7
8
8
9
from .exceptions import DBMutexError , DBMutexTimeoutError
9
10
from .models import DBMutex
@@ -83,7 +84,7 @@ def delete_expired_locks(self):
83
84
"""
84
85
ttl_seconds = self .get_mutex_ttl_seconds ()
85
86
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 ()
87
88
88
89
def __call__ (self , func ):
89
90
return self .decorate_callable (func )
Original file line number Diff line number Diff line change @@ -13,3 +13,6 @@ class DBMutex(models.Model):
13
13
"""
14
14
lock_id = models .CharField (max_length = 256 , unique = True )
15
15
creation_time = models .DateTimeField (auto_now_add = True )
16
+
17
+ class Meta :
18
+ app_label = 'db_mutex'
Original file line number Diff line number Diff line change 1
- __version__ = '0.2.2 '
1
+ __version__ = '0.2.3 '
Original file line number Diff line number Diff line change 1
1
Installation
2
2
============
3
3
4
- To install the latest release, type::
5
-
4
+ * Install Django-db-mutex with your favorite Python package manager::
5
+
6
+ # Using pip
6
7
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
7
11
8
- To install the latest code directly from source, type ::
12
+ * Add `` 'db_mutex' `` to your `` INSTALLED_APPS `` setting ::
9
13
10
- pip install git+git://github.com/ambitioninc/django-db-mutex.git
14
+ INSTALLED_APPS = (
15
+ # other apps
16
+ 'db_mutex',
17
+ )
Original file line number Diff line number Diff line change 1
- """
2
- Provides the ability to run test on a standalone Django app.
3
- """
4
1
import sys
5
2
from optparse import OptionParser
6
3
14
11
django .setup ()
15
12
16
13
# 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
18
15
19
16
20
17
def run_tests (* test_args , ** kwargs ):
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def configure_settings():
49
49
'django_nose' ,
50
50
),
51
51
DEBUG = False ,
52
- CACHES = {
52
+ CACHES = {
53
53
'default' : {
54
54
'BACKEND' : 'django.core.cache.backends.locmem.LocMemCache' ,
55
55
'LOCATION' : 'unique-snowflake'
Original file line number Diff line number Diff line change 1
- # import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
2
- import multiprocessing
3
- assert multiprocessing
4
1
import re
2
+ import multiprocessing
5
3
from setuptools import setup , find_packages
6
4
7
5
6
+ # import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
7
+ assert multiprocessing
8
+
9
+
8
10
def get_version ():
9
11
"""
10
12
Extracts the version number from the version.py file.
You can’t perform that action at this time.
0 commit comments