Jul-02-2020, 03:30 PM
Hi,
I've created a process in which I've used one while True loop for watch on a changeable variable. If the variable change something happens, otherwise the while loop rotates blank. This process is intended to be used in comparatively low resource machine, like Raspberry pi 4, 2GB.
My question is, will this ever rotating while True loop makes my process resource hungry, as it rotates at it's full speed until the conditions mate?
Please see the simplified code below:
Please help me to understand.
I'm a noob in python as well as programming.
______
Raspberry pi OS (32bit)
python 3.7x
I've created a process in which I've used one while True loop for watch on a changeable variable. If the variable change something happens, otherwise the while loop rotates blank. This process is intended to be used in comparatively low resource machine, like Raspberry pi 4, 2GB.
My question is, will this ever rotating while True loop makes my process resource hungry, as it rotates at it's full speed until the conditions mate?
Please see the simplified code below:
def do_something(): <something happens> changableVariable = <updated by other thread> comparingVariable = None while True: if changableVariable != comparingVariable: do_something() comparingVariable = changableVariableIn the above scenario until 'changableVariable' changes this while True loop [Line 7] is rotating in full speed after first run.
Please help me to understand.
I'm a noob in python as well as programming.
______
Raspberry pi OS (32bit)
python 3.7x