Code Monkey home page Code Monkey logo

Comments (4)

taylorchu avatar taylorchu commented on June 11, 2024

err = exec.CommandContext(ctx, cmd[0], cmd[1:]...).Run()

this will stop the command after deadline is exceeded. do you mean supporting context in handler?

from work.

genert avatar genert commented on June 11, 2024

You are correct, missed that part when reading the code.

However, it is confusing because I assume that the worker will take care of the context's deadline because that is what the job option MaxExecutionTime implies, no? Aka the job has max execution time.

What do you think about following logic instead:

  • after job has been dequeued and if job's MaxExecutionTime is not nil and greater than 0, then create timeout context with the option's duration value in the worker's loop
  • call handle
  • if context's <-ctx.Done() gets triggered before handle returns, then that job must be cancelled and retried with backoff

In that way, you do not have to define context.WithTimeout in job.

from work.

taylorchu avatar taylorchu commented on June 11, 2024

cancellation requires subfunctions to respect context timeout, and exit themselves, so we cannot do exactly what you said. but we could change the handler function signature to support it in the next major version.

from work.

taylorchu avatar taylorchu commented on June 11, 2024

done in #41

from work.

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.