pygame - python sched program possible timing issues -
so have number of events schedule varying delays such :
delays = [1,3,5,30, 40, 35, 12, 46, 52]
i schedule delays as:
s = sched.scheduler(time.time, time.sleep) lagtime in delays: s.enter(lagtime, 1, self.drawoncanvas, (arg1, arg2, arg3))
the function drawoncanvas doing pygame/opengl operations
the issue python time module has precision in seconds , want move in milliseconds. can set delays be:
delays = [x/1000 x in delays]
the scheduler takes arugment of time.time , time.sleep. can use datetime here instead , accomodate it?
second doing operations mouse , feels mouse being blocked scheduler. there way stop mouse being blocked?
edit: figured need non-blocking scheduler, threading method described here creates new thread ever timer event. there way make single thread invocation?
python time module has precision in seconds
not on modern platforms -- timestamps have fractional part, while unit of measure seconds, precision typically better milliseconds.
delays = [x/1000 x in delays]
that's ok in python 3, /
non-truncating. safety wrt python 2, you'd better off with
delays = [x/1000.0 x in delays]
apart that, existing scheduler should work fine. datetime
module has no sleep
functionality bit of work shoehorn in here (though feasible, don't see motivation work).
Comments
Post a Comment