What happens if pyglet.clock.schedule_interval can't keep up?

10 views
Skip to first unread message

Lo'oris

unread,
Nov 23, 2009, 12:42:01 PM11/23/09
to pyglet-users
Unless I'm missing something, the documentation doesn't take into
account the possibility of schedule_interval failing to actually do
what it's asked.

Since in real word this can happen, what do I have to expect when
there are other programs eating the cpu?
Will it just skip some ticks? Will they queue up and be called in a
non regular timing? What's going to happen?

Casey Duncan

unread,
Nov 23, 2009, 1:03:07 PM11/23/09
to pyglet...@googlegroups.com
As I understand the code, if the task does not get executed in time,
the next time it does execute, the scheduler will try to catch up by
scheduling the next one sooner, up to a certain threshold (i.e., it
won't schedule things in the past). So essentially your scheduled
thing will just get called less often than you expect if the OS does
not have enough cpu time to go around.

Since the time delta is passed to the scheduled callable, your code
can compensate according to this value. It's a good idea usually to
set an upper limit on how much compensation you do, however. In games
where physics is driven by the scheduler in this way, long time deltas
can make things unstable or unplayable. Lowering the framerate and
game speed at least lets the player continue with a degraded
experience rather than an unplayable one.

-Casey

Lo'oris

unread,
Nov 24, 2009, 6:29:59 AM11/24/09
to pyglet-users
On Nov 23, 7:03 pm, Casey Duncan <casey.dun...@gmail.com> wrote:
> As I understand the code, if the task does not get executed in time,
[...]

thank you :)
Reply all
Reply to author
Forward
0 new messages