Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame Clock - How long can it run for?

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.

like image 527
user7409496 Avatar asked Oct 30 '22 14:10

user7409496


1 Answers

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'>
like image 53
unwind Avatar answered Nov 15 '22 07:11

unwind