Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python & Django support #43

Merged
merged 2 commits into from
Jan 8, 2019
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ docs/_build
build/
dist/
*.egg-info
.tox
*.sqlite
44 changes: 19 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
dist: xenial

sudo: false

language: python

matrix:
include:
- python: "2.7"
env: TOX_ENV=py27-django18

- python: "3.4"
env: TOX_ENV=py34-django18
env: TOX_ENV=py27-django111

- python: "3.5"
env: TOX_ENV=py35-django18
env: TOX_ENV=py35-django111

- python: "3.6"
env: TOX_ENV=py36-django18

- python: "2.7"
env: TOX_ENV=py27-django110
env: TOX_ENV=py36-django111

- python: "3.4"
env: TOX_ENV=py34-django110
- python: "3.7"
env: TOX_ENV=py37-django111

- python: "3.5"
env: TOX_ENV=py35-django110
env: TOX_ENV=py35-django20

- python: "3.6"
env: TOX_ENV=py36-django110
env: TOX_ENV=py36-django20

- python: "2.7"
env: TOX_ENV=py27-django111

- python: "3.4"
env: TOX_ENV=py34-django111
- python: "3.7"
env: TOX_ENV=py37-django20

- python: "3.5"
env: TOX_ENV=py35-django111
env: TOX_ENV=py35-django21

- python: "3.6"
env: TOX_ENV=py36-django111
env: TOX_ENV=py36-django21

- python: "2.7"
env: TOX_ENV=flake8
- python: "3.7"
env: TOX_ENV=py37-django21

- python: "3.6"
env: TOX_ENV=flake8
script: tox -e $TOX_ENV
install:
- pip install tox

script:
- tox -e $TOX_ENV
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
CHANGELOG
=========

master
-----------

- Drop support of Python 3.4
- Confirm support of Python 3.7
- Drop support of Django 1.8
- Drop support of Django 1.10
- Confirm support of Django 2.0
- Confirm support of Django 2.1

Version 0.8
-----------

Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@ To run the tests, you'll need to install the development requirements::
Alternatively, you can run the tests with several versions of Django
and Python using tox:

pip install tox
tox
$ pip install tox

$ tox
7 changes: 1 addition & 6 deletions multidb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"""
import itertools
import random
from distutils.version import LooseVersion

import django
from django.conf import settings

from .pinning import this_thread_is_pinned, db_write # noqa
Expand All @@ -47,10 +45,7 @@
slaves = itertools.cycle(dbs)
# Set the slaves as test mirrors of the master.
for db in dbs:
if LooseVersion(django.get_version()) >= LooseVersion('1.7'):
settings.DATABASES[db].get('TEST', {})['MIRROR'] = DEFAULT_DB_ALIAS
else:
settings.DATABASES[db]['TEST_MIRROR'] = DEFAULT_DB_ALIAS
settings.DATABASES[db].get('TEST', {})['MIRROR'] = DEFAULT_DB_ALIAS
else:
slaves = itertools.repeat(DEFAULT_DB_ALIAS)

Expand Down
7 changes: 7 additions & 0 deletions multidb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,30 +215,37 @@ def test_multithreaded_unpinning(self):
thread2_lock = Lock()
thread1_lock.acquire()
thread2_lock.acquire()
orchestrator = Lock()
orchestrator.acquire()

pinned = {}

def thread1_worker():
with use_master:
orchestrator.release()
thread1_lock.acquire()

pinned[1] = this_thread_is_pinned()

def thread2_worker():
pin_this_thread()
with use_master:
orchestrator.release()
thread2_lock.acquire()

pinned[2] = this_thread_is_pinned()
orchestrator.release()

thread1 = Thread(target=thread1_worker)
thread2 = Thread(target=thread2_worker)

# thread1 starts, entering `use_master` from an unpinned state
thread1.start()
orchestrator.acquire()

# thread2 starts, entering `use_master` from a pinned state
thread2.start()
orchestrator.acquire()

# thread2 finishes, returning to a pinned state
thread2_lock.release()
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=["Django>=1.11"],
test_requires=['Fabric', 'django-nose'],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
# I don't know what exactly this means, but why not?
'Environment :: Web Environment :: Mozilla',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Python Modules',
]
)
6 changes: 3 additions & 3 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# The default database should point to the master.
DATABASES = {
'default': {
'NAME': 'master',
'NAME': 'master.sqlite',
'ENGINE': 'django.db.backends.sqlite3',
},
'slave': {
'NAME': 'slave',
'NAME': 'slave.sqlite',
'ENGINE': 'django.db.backends.sqlite3',
},
}
Expand All @@ -25,5 +25,5 @@

# If you use PinningMasterSlaveRouter and its associated middleware, you can
# customize the cookie name and its lifetime like so:
# MULTIDB_PINNING_COOKIE = 'multidb_pin_writes"
# MULTIDB_PINNING_COOKIE = "multidb_pin_writes"
# MULTIDB_PINNING_SECONDS = 15
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
[tox]
envlist = flake8,py{34}-django{18},py{27,34,35,36}-django{18,110,111}
envlist =
flake8
py{27,35,36,37}-django111
py{35,36}-django{20,21}

[testenv]
deps =
django18: Django>=1.8,<1.9
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
-rrequirements.txt

commands =
./run.sh test
python --version
pip freeze

[testenv:flake8]
Expand Down