question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a lock on tasks

See original GitHub issue

I have a lot of long-running tasks that I’m running using doit.

I often accidentally launch a task while it was already running. Having two processes running the same task often lead to issues:

  • use of the same resources
  • second task will overwrite the results of the first task
  • even if all goes well, I’ve wasted my CPU resources

I’d like to have a “locking” mechanism for a task. Is something like this already implemented ?

For now, I’m using a heuristic to check that a task isn’t already running right at the beginning of my code. But it would be nicer if the runner could do this for me, by e.g. storing a lock in the DB when a task is launched. The lock would need some kind of deadline in case doit crash and is unable to remove it, and the lock should probably be ignored with the doit run -a flag.

Is there a hook to write something before a task is run ? AFAIU value_savers are only called after the task is run.

And of course, thanks for the nice tool!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gwenzekcommented, May 23, 2019

Thanks for sharing this library.

I think this can be helpful for a workaround, but the main issue is I’m not sure what to do if I see a lock file.

  • I don’t want to mark the task as “uptodate” because I don’t want to trigger depending tasks
  • I don’t want to return a fake “success” value because I don’t want to trigger depending tasks
  • I don’t want to throw an error because it prevents doit to process other unrelated tasks

As a workaround I’m throwing an error if the lock file exists and use -c but I may end up skipping over other errors.

Currently a task has 3 possible status: {“up-to-date”, “run”, “error”} I’d like a 4th one: “delayed” which means that depending tasks can’t be executed but that doit should continue processing other tasks.

Do you think that would be a reasonable design ?

0reactions
schettino72commented, May 28, 2019

I’m proposing a 4th state “delayed” which means that the task is not ready to be run. Am I clearer ?

  • you a know a task is running
  • you ask doit to run it again
  • but you don’t want doit to execute the task

like that?i am assuming you have a complex dependency tree… otherwise you could just not run doit again. right?

not clear what would be the behavior of ‘delayed’. doit already has a delayed meaning task will be executed at a later stage by same process, seems thats not what you want.

maybe what you are looking for is what doit calls ‘ignore’… you would just need to to set it dynamicaly (not possible as of today)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Lock Unlock tasks - YouTube
How to lock /unlock tasks when routed to multiple users. ... How To Add An Outlet To A Finished Wall. Everyday Home Repairs....
Read more >
Configuring lock tasks - XebiaLabs documentation
Add a lock to task · Click the Release tab. · From the Show dropdown, select Release flow · Click menu button on...
Read more >
Lock task mode | Android Developers
An app in lock task mode can start new activities as long as the activity doesn't start a new task—except tasks that launch...
Read more >
Lock tasks - Digital.ai Documentation
Add a lock to task · In the top navigation bar, click Releases. · Click the Releases tab. · From the Show dropdown,...
Read more >
How to enable Lock Task Mode on Android devices - Hexnode
Enable lock task mode on your kiosk-enabled devices enrolled in Android Enterprise as device owner and disable all ... Tap on Policy Target...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found