# Blender not responding when starting a Python script

I have a python script what works/runs most of the time but sometimes it makes Blender "Not Responding" (I closed the program after ~20 mins). What is weird that it looks like it's not even starting, because there is nothing on the Console though my script starts with a print:

import bpy
import json
import csv
import math
import struct
import imghdr
import os
import subprocess
from enum import Enum

class RuncodeEnum(Enum):
GRAPHVIZ_FILES = 0
WAVEFRONT_OBJECT = 1
EXTRACT_COORDINATES = 2
GENERATE_CONNNECTIONS = 3
REINITIALIZE_SCENE = 4
IMPORT_OBJ_FILE = 5
TEST = 99

...

RUNCODE = RuncodeEnum.TEST

if __name__ == '__main__':
print("Starting script, RUNCODE is '" + RUNCODE.name + "'...")


(Beside these there are a few constants and methods, likely it's not relevant.)

Any good advice what am I might doing wrong?

• Bit hard to tell from that snippet. Often caused by infinite loops while True: for instance. Would also suggest not concatenating strings, by either using string formatting or for simple test prints: print("foo ", bar, 2000, "another string") – batFINGER Jan 29 '18 at 7:47
• Don't get me wrong, I'm not a Python expert, but the program "should" start at that point, but there is nothing on the Console which implies the script didn't even start. – Arklur Jan 29 '18 at 8:03
• Why is that the starting point? what is RUNCODE – batFINGER Jan 29 '18 at 8:16
• Oh yes, sorry. That's just an enum. – Arklur Jan 29 '18 at 8:30
• I see nothing in that code that will hang blender. How are you running this script. If run via "run script" operator, __name__ == "__main__" if autorun via registered script __name__ will be the module name, hence the if will never be true. – batFINGER Jan 29 '18 at 14:54