Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Separate lock backend from celery backend #22

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2c95a09
Refactored TaskManager to use its own separate backend independent of…
Salamek Apr 23, 2018
380dc13
Test rabbitmq
Salamek Apr 23, 2018
9835b18
Show unsupported backend message
Salamek Apr 23, 2018
a5c803b
Simple file locking
Salamek Apr 24, 2018
604efd4
Use timestamp in filesystem lock
Salamek Apr 24, 2018
2413dc3
Filesystem locking works as expected
Salamek Apr 24, 2018
8400a97
Use Filesystem locking backend as default when none is specified in c…
Salamek Apr 24, 2018
2661647
Fixes in sqlalchemy lock backend
Salamek Apr 24, 2018
f81ab7a
Added tests/test_database.sqlite
Salamek Apr 24, 2018
63febb2
Added .pytest_cache to .gitignore
Salamek Apr 24, 2018
d090f2e
Split project into multiple files
Salamek Apr 24, 2018
bb18fcd
Added tests for rabbitmq+redis/filesystem
Salamek Apr 24, 2018
99ca212
Does appveyor support rabbitmq ?
Salamek Apr 24, 2018
7e44228
Remove useless to_dict
Salamek Apr 24, 2018
be4f364
Handle ProgrammingError duplicate unique key
Salamek Apr 24, 2018
75b3f79
Exception: SQLAlchemy requires Python 2.7 or higher.
Salamek Apr 24, 2018
01a245a
Added missing depedencies
Salamek Apr 24, 2018
b85c08d
Added missing author/licence/version
Salamek Apr 24, 2018
92762f8
Docs
Salamek Apr 24, 2018
8d01501
Fix lint and use python3.6
Salamek Apr 24, 2018
9989ba0
Oops stupid bug!
Salamek Apr 24, 2018
eb9e0a0
Remove python33 from appveyor
Salamek Apr 24, 2018
f3c41fd
Install rabbitmq
Salamek Apr 24, 2018
49e1f07
Install rabbitmq only for rabbit_redis
Salamek Apr 25, 2018
fd1e115
Allow rabbit_filesystem
Salamek Apr 25, 2018
c550566
Added CELERY_TASK_LOCK_BACKEND to examples
Salamek Apr 25, 2018
9a1e98f
Try to cache chocolatey on appveyor
Salamek Apr 25, 2018
16a008c
Lets try to wait for rabbitmq to start
Salamek Apr 27, 2018
451c58d
Fix version info in README
Salamek Apr 27, 2018
d61fc3f
Meh
Salamek Apr 27, 2018
208db4f
Put rabbit tests at start
Salamek Apr 27, 2018
2bf0ca4
Print message to check that script is run
Salamek Apr 27, 2018
6efff86
I'm copy monkey :(
Salamek Apr 27, 2018
dbb5cb7
Attempt to fix rabbitmq install
Salamek Jun 16, 2018
b2e0f03
Fix
Salamek Jun 16, 2018
eb6213d
Rewrite test env setup
Salamek Jun 17, 2018
c88b9dd
Fix rabbit install for appveyor
Salamek Jun 17, 2018
483b775
Added missing executable flag on setup.sh
Salamek Jun 17, 2018
e52c71c
Add correct prefix when using SQL databases
Salamek Jun 17, 2018
b022e3b
Drop Python3.3 support (it is not supported in new wheel)
Salamek Jun 17, 2018
b9c7543
Remove debug print
Salamek Jun 17, 2018
fc72d02
Little bit better coverage for backend and filesystem_backend.
Salamek Jun 17, 2018
9c04b2b
Use tempfile.gettempdir()
Salamek Jun 17, 2018
08e0d19
Add slash to hopefully fix win tests
Salamek Jun 18, 2018
b753756
Windows ? Now ? Maybe ?
Salamek Jun 18, 2018
cfc8012
Rename variable all_envs -> all_env_variables
Salamek Jun 18, 2018
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 @@ -40,6 +40,7 @@ htmlcov/
.coverage
.coverage.*
.cache
.pytest_cache
nosetests.xml
coverage.xml
*,cover
Expand Down Expand Up @@ -93,3 +94,4 @@ ENV/
.idea/
requirements*.txt
.DS_Store
tests/test_database.sqlite
31 changes: 15 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# Configure.
language: python
python:
- 3.6
- 3.4
- 3.3
- pypy
- 2.7
- 2.6
services: [redis-server]
services:
- redis-server
- rabbitmq
sudo: false

# Environment and matrix.
env:
- BROKER: sqlite
- BROKER: mysql
- BROKER: postgres
- BROKER: redis
- BROKER: redis_sock,/tmp/redis.sock
- BROKER=sqlite RESULT=sqlite LOCK=sqlite
- BROKER=mysql RESULT=mysql LOCK=mysql
- BROKER=rabbit RESULT=redis LOCK=redis
- BROKER=rabbit RESULT=redis LOCK=filesystem
- BROKER=postgres RESULT=postgres LOCK=postgres
- BROKER=redis RESULT=redis LOCK=redis
- BROKER=redis_sock RESULT=redis_sock LOCK=redis_sock
matrix:
include:
- python: 3.4
- python: 3.6
services: []
env: TOX_ENV=lint
before_script: []
Expand All @@ -27,12 +30,8 @@ matrix:
# Run.
install: pip install tox
before_script:
- if [[ $BROKER == redis_sock* ]]; then echo -e "daemonize yes\nunixsocket /tmp/redis.sock\nport 0" |redis-server -; fi
- if [ $BROKER == mysql ]; then mysql -u root -e 'CREATE DATABASE flask_celery_helper_test;'; fi
- if [ $BROKER == mysql ]; then mysql -u root -e 'GRANT ALL PRIVILEGES ON flask_celery_helper_test.* TO "user"@"localhost" IDENTIFIED BY "pass";'; fi
- if [ $BROKER == postgres ]; then psql -U postgres -c 'CREATE DATABASE flask_celery_helper_test;'; fi
- if [ $BROKER == postgres ]; then psql -U postgres -c "CREATE USER user1 WITH PASSWORD 'pass';"; fi
- if [ $BROKER == postgres ]; then psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE flask_celery_helper_test TO user1;'; fi
- ./testdata/travis/setup.sh

script: tox -e ${TOX_ENV:-py}
after_success:
- bash <(curl -s https://codecov.io/bash)
Expand All @@ -47,5 +46,5 @@ deploy:
bKa8bxjRurUEHedjV9UG9fVZwVsWU981aWOxeEl+6kLkpJ2fE9UVeK7T1O+RzzhkWhHq2/YL\
4BjBqzOLuBSAGnXZAnwH55Z6HY2g="
on:
condition: $TRAVIS_PYTHON_VERSION = 3.4
condition: $TRAVIS_PYTHON_VERSION = 3.6
tags: true
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ I need an init_app() method to initialize Celery after I instantiate it.

This extension also comes with a ``single_instance`` method.

* Python 2.6, 2.7, PyPy, 3.3, and 3.4 supported on Linux and OS X.
* Python 2.7, 3.3, and 3.4 supported on Windows (both 32 and 64 bit versions of Python).
* Python 2.6, 2.7, PyPy, 3.3, 3.4 and 3.6 supported on Linux and OS X.
* Python 2.7, 3.4 and 3.6 supported on Windows (both 32 and 64 bit versions of Python).

.. image:: https://img.shields.io/appveyor/ci/Robpol86/Flask-Celery-Helper/master.svg?style=flat-square&label=AppVeyor%20CI
:target: https://ci.appveyor.com/project/Robpol86/Flask-Celery-Helper
Expand Down Expand Up @@ -64,6 +64,7 @@ Basic Example
app = Flask('example')
app.config['CELERY_BROKER_URL'] = 'redis://localhost'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost'
app.config['CELERY_TASK_LOCK_BACKEND'] = 'redis://localhost'
celery = Celery(app)

@celery.task()
Expand Down Expand Up @@ -102,6 +103,7 @@ Factory Example
app.config['CELERY_IMPORTS'] = ('tasks.add_together', )
app.config['CELERY_BROKER_URL'] = 'redis://localhost'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost'
app.config['CELERY_TASK_LOCK_BACKEND'] = 'redis://localhost'
celery.init_app(app)
return app

Expand Down Expand Up @@ -137,6 +139,7 @@ Single Instance Example
app.config['REDIS_URL'] = 'redis://localhost'
app.config['CELERY_BROKER_URL'] = 'redis://localhost'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost'
app.config['CELERY_TASK_LOCK_BACKEND'] = 'redis://localhost'
celery = Celery(app)
Redis(app)

Expand Down
152 changes: 135 additions & 17 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,212 @@ services:
- mysql
- postgresql

cache:
- "%HOMEDRIVE%%HOMEPATH%\rabbitmq-server-3.7.6.exe"

# Environment and matrix.
environment:
PATH: C:\%PYTHON%;C:\%PYTHON%\Scripts;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\PostgreSQL\9.5\bin;%PATH%
PGPASSWORD: Password12!
PYTHON: Python34
PYTHON: Python36
matrix:
- TOX_ENV: lint
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py34
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py36
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py27
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python36-x64
BROKER: rabbit
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: rabbit
RESULT: redis
LOCK: redis

- TOX_ENV: lint
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py34
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py36
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py27
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py
PYTHON: Python36-x64
BROKER: rabbit
RESULT: redis
LOCK: filesystem
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: rabbit
RESULT: redis
LOCK: filesystem


- TOX_ENV: lint
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py34
BROKER: sqlite
- TOX_ENV: py33
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py36
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py27
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py
PYTHON: Python33-x64
PYTHON: Python36-x64
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: sqlite
RESULT: sqlite
LOCK: sqlite

- TOX_ENV: lint
BROKER: mysql
RESULT: mysql
LOCK: mysql
- TOX_ENV: py34
BROKER: mysql
- TOX_ENV: py33
RESULT: mysql
LOCK: mysql
- TOX_ENV: py36
BROKER: mysql
RESULT: mysql
LOCK: mysql
- TOX_ENV: py27
BROKER: mysql
RESULT: mysql
LOCK: mysql
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: mysql
RESULT: mysql
LOCK: mysql
- TOX_ENV: py
PYTHON: Python33-x64
PYTHON: Python36-x64
BROKER: mysql
RESULT: mysql
LOCK: mysql
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: mysql
RESULT: mysql
LOCK: mysql

- TOX_ENV: lint
BROKER: postgres
RESULT: postgres
LOCK: postgres
- TOX_ENV: py34
BROKER: postgres
- TOX_ENV: py33
RESULT: postgres
LOCK: postgres
- TOX_ENV: py36
BROKER: postgres
RESULT: postgres
LOCK: postgres
- TOX_ENV: py27
BROKER: postgres
RESULT: postgres
LOCK: postgres
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: postgres
RESULT: postgres
LOCK: postgres
- TOX_ENV: py
PYTHON: Python33-x64
PYTHON: Python36-x64
BROKER: postgres
RESULT: postgres
LOCK: postgres
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: postgres
RESULT: postgres
LOCK: postgres

- TOX_ENV: lint
BROKER: redis
RESULT: redis
LOCK: redis
- TOX_ENV: py34
BROKER: redis
- TOX_ENV: py33
RESULT: redis
LOCK: redis
- TOX_ENV: py36
BROKER: redis
RESULT: redis
LOCK: redis
- TOX_ENV: py27
BROKER: redis
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python34-x64
BROKER: redis
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python33-x64
PYTHON: Python36-x64
BROKER: redis
RESULT: redis
LOCK: redis
- TOX_ENV: py
PYTHON: Python27-x64
BROKER: redis
RESULT: redis
LOCK: redis

# Run.
build_script: pip install tox
after_build:
- IF %BROKER% EQU redis cinst redis-64
- IF %BROKER% EQU redis redis-server --service-install
- IF %BROKER% EQU redis redis-server --service-start
- IF %BROKER% EQU mysql mysql -u root -p"Password12!" -e "CREATE DATABASE flask_celery_helper_test;"
- IF %BROKER% EQU mysql mysql -u root -p"Password12!" -e "GRANT ALL PRIVILEGES ON flask_celery_helper_test.* TO 'user'@'localhost' IDENTIFIED BY 'pass';"
- IF %BROKER% EQU postgres psql -U postgres -c "CREATE DATABASE flask_celery_helper_test;"
- IF %BROKER% EQU postgres psql -U postgres -c "CREATE USER user1 WITH PASSWORD 'pass';"
- IF %BROKER% EQU postgres psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE flask_celery_helper_test TO user1;"
- ps: .\testdata\appveyor\setup.ps1

test_script: tox -e %TOX_ENV%
on_success: IF %TOX_ENV% NEQ lint pip install codecov & codecov
Loading