[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
master
What happened?
Job.started_at is never set.
My use case is a structlog processor that adds info from Job into the log document that I generate.
As Job is frozen, simply setting the value in AsyncScheduler._run_job() won't work, perhaps a setter method on Job that puts the value directly into Job.__dict__ uses object.__setattr__()?
How can we reproduce the bug?
from __future__ import annotations
from asyncio import run
from apscheduler import AsyncScheduler, current_job
from apscheduler.triggers.interval import IntervalTrigger
def tick():
job = current_job.get()
print(f"Job started at: {job.started_at}")
async def main():
async with AsyncScheduler() as scheduler:
await scheduler.add_schedule(tick, IntervalTrigger(seconds=1))
await scheduler.run_until_stopped()
run(main())
Example output:
Job started at: None
Job started at: None
Job started at: None
...
Things to check first
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
master
What happened?
Job.started_at
is never set.My use case is a structlog processor that adds info from
Job
into the log document that I generate.As
Job
is frozen, simply setting the value inAsyncScheduler._run_job()
won't work, perhaps a setter method onJob
thatputs the value directly intousesJob.__dict__
object.__setattr__()
?How can we reproduce the bug?
Example output:
Possible solution