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
22import functools
33import logging
44
55from django .conf import settings
66from django .db import transaction , IntegrityError
7+ from django .utils import timezone
78
89from .exceptions import DBMutexError , DBMutexTimeoutError
910from .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 )
Original file line number Diff line number Diff 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'
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 11Installation
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+ )
Original file line number Diff line number Diff line change 1- """
2- Provides the ability to run test on a standalone Django app.
3- """
41import sys
52from optparse import OptionParser
63
1411django .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
2017def run_tests (* test_args , ** kwargs ):
Original file line number Diff line number Diff 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'
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
41import re
2+ import multiprocessing
53from 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+
810def get_version ():
911 """
1012 Extracts the version number from the version.py file.
You can’t perform that action at this time.
0 commit comments