How can I make an infinite loop in Python in Blender？ I ran a simple program like this:

while True:
    print("test")


If I do so, nothing will be output with the screen frozen. 

With other software, this is not the case, and it is printed properly.

Is Blender not able to do this?

Is there any workaround?



The reason I want to do this is because I want to communicate with an external application using Blender.

For example, “while true:” appears in the program as introduced in the following video.
https://www.youtube.com/watch?v=4xZRfzOtxzA

However, there is no error in the sample program in the video.



I also tried running the following program.

i = 0
while True:
    print("test")
    i+=1
    if i == 1000000:
        break


Then, the screen does not freeze, but "test" is not printed every time a while loop.

But "test" is printed all at once after all while loops have finished.

This does not happen when you run Python from Autodesk Maya or the Windows command prompt.

Normally, "test" is printed for each while loop.

Why is Blender such a specification?

I want to know under what conditions I can turn the while loop without freezing.
Blender scripts are not subprocesses: if you trigger an infinite loop in a script/addon, Blender will freeze as well until the script finishes what it is doing.

The reason why you can't see an outout is that Blender's print() funtion displays the text in the console window, that you can open in Window -> Toggle System Console

If you execute your script then you'll see that your text keeps being written and the script is working



If your code is very long you could make it a subprocess or execute externally (but you rarely need to do it), while if you just need to execute it once in a while you can use modal operators

with modal operators, for instance, you can  execute your script every 0.1 seconds and make it print your text, so in that 0.1 second Blender has time to update the UI