I do not know what you mean by "race condition". As you said, it is just a bug demo. In real, the same events as these in this short script occur in different objects. The code is very complicated and I don't want go into describing it.
Race Condition. In this particular case, one process is opening a file that may or may not be created yet. If it does succeed in opening it, it may read the contents of the previous run of the program. If it doesn't succeed, it loops forever.