5

I use Python and pygame for a control and automation task. Information from a sensor is displayed using pygame then is recorded elsewhere.
To limit the framerate I am using the pygame clock tick.

As this is an embedded application the process could be running for months at a time. Will the pygame clock ever stop working i.e. if it stores the ms as an integer (long integer whatever) when will it run out of time and can it cope with going back round to 0 (or worse minus something)?

If it does run out how long will it work for? I seem to remember the first version of Win95 crashed after 4 days for this reason!

I'm usisg Python2.7 on a Raspberry Pi ver 3 if this is relevent.

1 Answers1

2

Python 2.7.x has two integer types: "plain integers" and "long integers". The former are basically long ints in C, which should be at least 32 bits. The latter are unlimited. Since calculations automatically convert into long if needed, you should be fine.

Example:

Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
>>> x=1<<30
>>> x
1073741824
>>> type(x)
<type 'int'>
>>> x+=1<<30
>>> x
2147483648L
>>> type(x)
<type 'long'>
unwind
  • 391,730
  • 64
  • 469
  • 606
  • OK, So as long as there is nothing internal in the pygame library stating that the ms timer is an int it'll work forever. If it is a fixed 32 bit integer that'll give me 25 or 50 days runtime (depending on if it is signed) if the clock.tick method does not handle the clock going back to zero (or -2^31) properly). – user7409496 Jan 12 '17 at 13:41