dbader / dbader/schedule

How to handle jobs that return values?

Open
#547 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
12.3k
Forks
999
PR merge metrics
No merged PRs in 30d

Description

Sorry in advance if this is already documented somewhere, can't find it yet.

I have functions that return values, and I'm struggling to see how to factor that into the way you schedule and run jobs with this library.
Example, a function called `getData()` that does a API get request, and returns a variable called `data`
Then a function called `processData(data)` that takes the data and does something with it.

In my example, I'd like to only run `getData()` once every 48 hours, but I need to run `processData(data)` every hour. (The reason for this is that the data feed via API doesn't refresh very often, so I don't need to call it every hour).

I see the syntax for defining the scheduling parameters be:
```
schedule.every(48).hours.do(getData)
schedule.every(1).hours.do(processData)
```
but how do I handle the `data` variable returned by `getData()`

All the examples I've found so far with schedule are jobs that don't return values.
If I need my jobs to share data with each other, maybe I need to use global variables?

Any help much appreciated, thanks.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the scheduling API around schedule.every(...).do(...) and how job return values are handled. Clarify whether scheduled jobs can share getData()'s result with processData(data), document the supported approach or limitation, and ensure the example's 48-hour and hourly schedules are accurately explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.