Skip to content
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
5 changes: 3 additions & 2 deletions db_mutex/db_mutex.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from datetime import datetime, timedelta
from datetime import timedelta
import functools
import logging

from django.conf import settings
from django.db import transaction, IntegrityError
from django.utils import timezone

from .exceptions import DBMutexError, DBMutexTimeoutError
from .models import DBMutex
Expand Down Expand Up @@ -83,7 +84,7 @@ def delete_expired_locks(self):
"""
ttl_seconds = self.get_mutex_ttl_seconds()
if ttl_seconds is not None:
DBMutex.objects.filter(creation_time__lte=datetime.utcnow() - timedelta(seconds=ttl_seconds)).delete()
DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()

def __call__(self, func):
return self.decorate_callable(func)
Expand Down
3 changes: 3 additions & 0 deletions db_mutex/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ class DBMutex(models.Model):
"""
lock_id = models.CharField(max_length=256, unique=True)
creation_time = models.DateTimeField(auto_now_add=True)

class Meta:
app_label = 'db_mutex'
2 changes: 1 addition & 1 deletion db_mutex/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.2'
__version__ = '0.2.3'
15 changes: 11 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
Installation
============

To install the latest release, type::

* Install Django-db-mutex with your favorite Python package manager::

# Using pip
pip install django-db-mutex

# Or, using pip (from source, in editable form)
pip install -e git://github.com/ambitioninc/django-db-mutex.git#egg=django-db-mutex

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

pip install git+git://github.com/ambitioninc/django-db-mutex.git
INSTALLED_APPS = (
# other apps
'db_mutex',
)
5 changes: 1 addition & 4 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
Provides the ability to run test on a standalone Django app.
"""
import sys
from optparse import OptionParser

Expand All @@ -14,7 +11,7 @@
django.setup()

# Django nose must be imported here since it depends on the settings being configured
from django_nose import NoseTestSuiteRunner
from django_nose import NoseTestSuiteRunner # noqa


def run_tests(*test_args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def configure_settings():
'django_nose',
),
DEBUG=False,
CACHES = {
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake'
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
import multiprocessing
assert multiprocessing
import re
import multiprocessing
from setuptools import setup, find_packages


# import multiprocessing to avoid this bug (http://bugs.python.org/issue15881#msg170215)
assert multiprocessing


def get_version():
"""
Extracts the version number from the version.py file.
Expand Down