Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add milliseconds support for the interval scheduler #323

Closed
wants to merge 3 commits into from

Conversation

aradler
Copy link

@aradler aradler commented Jul 25, 2018

Because of the way you implemented this (using timedeltas), the change involves very few lines of code.

I opted out of implementing this as microseconds, as it is unlikely that a scheduler running on any normal computer could actually uphold microsecond precision.

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.6%) to 89.974% when pulling 04d73c4 on aradler:master into 18b50d9 on agronholm:master.

1 similar comment
@coveralls
Copy link

coveralls commented Jul 25, 2018

Coverage Status

Coverage decreased (-3.6%) to 89.974% when pulling 04d73c4 on aradler:master into 18b50d9 on agronholm:master.

@agronholm
Copy link
Owner

The same would hold true for milliseconds too, at least when using a persistent job store. What is your use case for millisecond accuracy anyway?

@aradler
Copy link
Author

aradler commented Jul 25, 2018

I am interfacing with an API that allows three requests per second, and I would like to be able to request as much data as possible.

I installed my fork's version of the package into my project, and found that I have roughly +/- 2 milliseconds on most queries. I haven't done any long haul or heavy load testing; are there any tests that I could add that you think would provide a useful insight to the precision in all cases? I'm considering writing a test case that simply starts a few timers with some millisecond duration, lets them all run and log the times that they actually run at, and ensuring that the precision is within some factor. My biggest concern here, though, is that test would likely run different on different (especially slower) platforms.

@agronholm
Copy link
Owner

I will consider this for the next release.

@gusutabopb
Copy link

+1

I was looking for this exact functionality so it'd be really nice to have it in a proper release.

My use case is that need to run some jobs with a 100~500ms frequency for a trading system.

DateTrigger already supports sub-second triggers (since it takes any datetime object), this PR should add IntervalTrigger support and adding CronTrigger support also doesn't seem too hard (I can submit another PR for that if the library author thinks this would be nice to have).

@agronholm
Copy link
Owner

I'm hoping to set some time aside this summer to work on APScheduler 4.0. Note that the scheduler is not real-time and won't be in the foreseeable future, but the ability to specify execution times on the millisecond level has been requested by quite a few people so I think I'll just go ahead and do it. Just don't complain if the jobs don't exactly start at the designated sub-second times.

@thedrow
Copy link

thedrow commented Jun 23, 2019

We need this for Celery 5.

@agronholm
Copy link
Owner

Millisecond intervals are supported in master.

@agronholm agronholm closed this Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants