Comments (10)
Something like:
@classmethod
def async_or_eager(self, **options):
"""
modified the delay_or_eager method to follow the apply_async signature
"""
possible_broker_errors = self._get_possible_broker_errors_tuple()
try:
return self.apply_async(**options)
except possible_broker_errors:
return self.apply(**options)
@classmethod
def async_or_fail(self, **options):
"""
modified the delay_or_fail method to follow the apply_async signature
"""
possible_broker_errors = self._get_possible_broker_errors_tuple()
try:
return self.apply_async(**options)
except possible_broker_errors as e:
return self.simulate_async_error(e)
from jobtastic.
That looks like a good function signature, to me. I'm +1 on adding that.
from jobtastic.
Had not attempted to use the previous code. Needed to modify to match the way JobtasticTask.apply_async expects args/kwargs
@classmethod
def async_or_eager(self, **options):
"""
modified the delay_or_eager method to follow the apply_async signature
"""
args = options.pop("args", None)
kwargs = options.pop("kwargs", None)
possible_broker_errors = self._get_possible_broker_errors_tuple()
try:
return self.apply_async(args, kwargs, **options)
except possible_broker_errors:
return self.apply(args, kwargs, **options)
@classmethod
def async_or_fail(self, **options):
"""
modified the delay_or_fail method to follow the apply_async signature
"""
args = options.pop("args", None)
kwargs = options.pop("kwargs", None)
possible_broker_errors = self._get_possible_broker_errors_tuple()
try:
return self.apply_async(args, kwargs, **options)
except possible_broker_errors as e:
return self.simulate_async_error(e)
from jobtastic.
I am going to use this for a little while in an abstract task subclass to make sure there are no issues and then I will put together a pull request
from jobtastic.
That sounds excellent! If you could also give documenting these new methods a shot, that would be appreciated. It seems like immediately after the delay_or_fail section might be a good spot.
As far as testing, I think we should be able to get away with just adding the async_or_fail_FOO
and async_or_eager_FOO
permutations to BrokenBrokerTestCase and to WorkingBrokerTestCase. That should be enough coverage to keep things stable.
Looking forward to hearing how things go when you try this out.
-Wes
from jobtastic.
PR submitted with code/tests/docs. It seems like everything will pass but still running at the moment
from jobtastic.
@winhamwr Have you had a chance to look over this PR?
from jobtastic.
@winhamwr not trying to pester you... but just checking back in on this one too
from jobtastic.
@winhamwr any chance of a pypi release with this PR in it?
from jobtastic.
New version up on PyPi
from jobtastic.
Related Issues (20)
- Add option to skip herd avoidance check, but still trigger avoidance for other tasks HOT 19
- compatibility with Celery 4.0? HOT 3
- Project configuration HOT 4
- celery.conf deprecated HOT 2
- License mismatch HOT 1
- Python core dump or memcached/redis I/O error can cause other-process `apply_async` to loop for `thundering_herd_timeout` HOT 4
- Add option to retry a task later if the task is already running HOT 1
- Add ability to ensure only 1 version of a task is running at a time, but still actually run subsequent jobs: Simultaneous Execution Prevention HOT 3
- Add support for Celery >= 4.0 HOT 11
- How do you handle POST -> REDIRECT -> GET sequence to pass task_id? HOT 2
- groups or subtask HOT 1
- old requirements of psutil clashes
- Herd Avoidance and Task Retry HOT 1
- Jobtastic tasks waits even CELERY_TASK_ALWAYS_EAGER is True
- Magic value (-1) for cache TTL is not compatible with cachelib RedisCache.
- Expose method to extend lock timeout HOT 1
- jquery-celery is dead ...
- Caching task even though cache_duration = -1 HOT 7
- cache locking allows bypassing herd avoidance
- Support for celery 5.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jobtastic.