Giter Site home page Giter Site logo

Comments (10)

thenewguy avatar thenewguy commented on July 17, 2024

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.

winhamwr avatar winhamwr commented on July 17, 2024

That looks like a good function signature, to me. I'm +1 on adding that.

from jobtastic.

thenewguy avatar thenewguy commented on July 17, 2024

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.

thenewguy avatar thenewguy commented on July 17, 2024

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.

winhamwr avatar winhamwr commented on July 17, 2024

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.

thenewguy avatar thenewguy commented on July 17, 2024

PR submitted with code/tests/docs. It seems like everything will pass but still running at the moment

from jobtastic.

thenewguy avatar thenewguy commented on July 17, 2024

@winhamwr Have you had a chance to look over this PR?

from jobtastic.

thenewguy avatar thenewguy commented on July 17, 2024

@winhamwr not trying to pester you... but just checking back in on this one too

from jobtastic.

thenewguy avatar thenewguy commented on July 17, 2024

@winhamwr any chance of a pypi release with this PR in it?

from jobtastic.

jlward avatar jlward commented on July 17, 2024

New version up on PyPi

from jobtastic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.