python - my code is always printing "COMPLETED" and dont exit the while loop -


i have mapreducejob define jobid:

jobid = emr.run_jobflow(name="data processing" 

after mapreduce job want show message "completed job" when mapreduce job status == "completed".

im trying code below, im having status like:

starting starting .... running ... completed completed completed completed

the problem is printing "completed" , dont exit while loop. , want exit shows message "completed job".

do see issue is?

status = emr.describe_jobflow(jobid)      while status.state != 'completed' or status.state != 'failed':           status = emr.describe_jobflow(jobid)     print status.state  print "job status:" + str(status.state) print "" print "completed job" 

while status.state != 'completed' or status.state != 'failed': 

this line evaluates true. when state "completed", evaluates false or true, true. when state "failed", evaluates true or false, true. when state else, evaluates true or true, true. loop continues infinitely.

the equivalent of "until or b" not "while not or not b", it's "while not , not b". see de morgan's laws more detail.

replace or and.

while status.state != 'completed' , status.state != 'failed':  

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -