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 func parameter in `remove_job`

See original GitHub issue

Describe the solution you’d like Currently:

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger

scheduler = AsyncIOScheduler()

async def foo():
    ...

scheduler.add_job(foo, id="abc", CronTrigger(minute="10"))
scheduler.remove_job("abc")  # will remove the job with the id "abc"

Enhancement:

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger

scheduler = AsyncIOScheduler()

async def foo():
    ...

scheduler.add_job(foo, id="abc", CronTrigger(minute="10"))
scheduler.remove_job(foo)  # will remove the job with the func foo

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
agronholmcommented, Aug 25, 2021

Other user have different needs. Some software allow multiple users to add schedules dynamically, so the same function could be scheduled by multiple users separately.

0reactions
r-priyamcommented, Aug 25, 2021

If somebody has added multiple jobs with foo(), should they all be removed?

Inside foo()? Yes Multiple functions with the name foo? Don’t know if someone would like to have same function name in same file…it’s kinda like breaking python laws

I think what @agronholm is referring to, is that you can have multiple schedules of the same function with different parameters. By removing a job using only the function parameter, this would need to remove all instances of the schedule using that function, which is probably undesirable behaviour.

Owh hmm. I haven’t seen any use cases of it roughly but can be in some rare cases. In our team none uses that in that way and all functions are used for registering one event only.

Quite unsure that why someone will use it in that way as CronTrigger is very flexible and can schedule any job easily.

If a user is removing one job then it can also have a possibility that they won’t need other job too.

If any user have multiple jobs register for one function then they will have to remove all from the Id’s and hence using a function removal can be easy here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove-Job (Microsoft.PowerShell.Core)
The Remove-Job cmdlet deletes PowerShell background jobs that were started by the ... Or, use Remove-Job with the Force parameter to delete a...
Read more >
gocron to add and remove task dynamically with parameter
you can handle the removal logic by deduplicating the function handlers. package main import ( "fmt" ) func main() { fn1 := func() ......
Read more >
Arrow function expressions - JavaScript - MDN Web Docs
Remove the word "function" and place arrow between the argument and opening ... With arrow functions, since our add function is essentially ...
Read more >
Pass by reference (C++ only) - IBM
The reference parameters are initialized with the actual arguments when the function is called. CCNX06A #include <stdio.h> void swapnum(int &i, int &j) {...
Read more >
Python Functions - W3Schools
You can add as many arguments as you want, just separate them with a comma. The following example has a function with one...
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