agronholm / apscheduler

Task scheduling library for Python
MIT License
5.94k stars 690 forks source link

Save results of scheduler jobs, version: 4.0.0a5 #927

Open HK-Mattew opened 2 weeks ago

HK-Mattew commented 2 weeks ago

Things to check first

Feature description

This is a suggestion for the new version: 4.0.0a5

I saw that you can save the results of individual jobs in apscheduler. However, it doesn't have or I didn't find the option to save the results of jobs from a scheduler added with Scheduler.add_schedule. (I looked through all the documentation and couldn't find it).

I believe it would be worth adding this feature to Scheduler.add_schedule to be able to save the results of all jobs executed by the scheduler.

That's my suggestion. I apologize if this doesn't make sense to you.

Use case

I believe it is essential to be able to have the results of the scheduler's work, as this would be useful for several occasions.

As this is not yet supported, I would have to add a scheduler to create jobs with the option to save job results (I believe this is not very interesting).

agronholm commented 2 weeks ago

You say this is essential, but you provide no reasoning of why it would be essential. I left out this possibility precisely because I figured it wouldn't be essential. I see it as a big footgun, as it would continuously add more data to the database automatically.

HK-Mattew commented 2 weeks ago

You say this is essential, but you provide no reasoning of why it would be essential. I left out this possibility precisely because I figured it wouldn't be essential. I see it as a big footgun, as it would continuously add more data to the database automatically.

Specifically in my use case it would be: A scheduler that generates reports with website statistics on certain days/months (and others). And the preference for saving the results of the scheduler's jobs is that I could always use the apscheduler instance itself to get the results of my results for a certain type of report and among others.

You said you see it as a firearm. I don't believe it is, as activating the option to save the results of work would be up to whoever is using it and this option would be disabled by default. And of course, whoever activated this knows the possibilities (And I also believe that the result_expiration_time of the job could be specified, so it wouldn't cause so much confusion).

WillDaSilva commented 2 weeks ago

@HK-Mattew have you considered having your scheduled jobs explicitly save their results to a persistent data store at the end of their execution?

HK-Mattew commented 2 weeks ago

@HK-Mattew have you considered having your scheduled jobs explicitly save their results to a persistent data store at the end of their execution?

Hello

Yes, I use it like that at the moment.

However, I would find it interesting to be able to get results through the scheduler instance, as I could get the results for the specific id of a task. And another reason would also be to have all the scheduler data, all jobs centralized in just one database and one database collection. Since I use MongoDB's DataStore.

I know I could do all this manually on my own, but why not take advantage of apscheduler for this? I think it would be good.

Of course, this is just an idea that popped into my mind. But if this doesn't make sense to other apscheduler users and developers. There's no need to integrate this.