Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bigjools/issue/14
Signal job failures when recovering dead jobs
- Loading branch information
Showing
10 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ doc/_build | |
|
||
.coverage | ||
.pytest_cache | ||
|
||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
import time | ||
|
||
from spinach.brokers.memory import MemoryBroker | ||
from spinach.brokers.redis import RedisBroker | ||
from spinach.engine import Engine | ||
|
||
|
||
@pytest.fixture(params=[MemoryBroker, RedisBroker]) | ||
def spin(request): | ||
broker = request.param | ||
spin = Engine(broker(), namespace='tests') | ||
yield spin | ||
|
||
|
||
def test_concurrency_limit(spin): | ||
count = 0 | ||
|
||
@spin.task(name='do_something', max_retries=10, max_concurrency=1) | ||
def do_something(index): | ||
nonlocal count | ||
assert index == count | ||
count += 1 | ||
|
||
for i in range(0, 5): | ||
spin.schedule(do_something, i) | ||
|
||
# Start two workers; test that only one job runs at once as per the | ||
# Task definition. | ||
spin.start_workers(number=2, block=True, stop_when_queue_empty=True) | ||
assert count == 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ deps = | |
pytest-cov | ||
pytest-threadleak | ||
pycodestyle | ||
flake8 | ||
flask | ||
django | ||
|
||
|