Preventing crashes when running script

As of using the text editor from time to time, crashes happen very frequently for me. You know trying and testing things, everything goes.

To put things in place, I have no problem at all with the crashes, I expect them to happen when doing all kinds of things with the BPY. I am only annoyed for loosing the script in progress. Perhaps you might say to save a temp blend file, and save often before running, good point. The big picture however, is that makes Blender look unprofessional, crashing rather easily even if it is on purpose or by mistake, the best thing is this to be prevent from happing.

About the implementation, using a new thread it will be much more tricky, as multithreading is a bit more complex topic and it will have more movable parts to implement.

So perhaps one possible and quick fix, is to run the code inside a try-catch block so at least we have some kind of safety measure. Not that we expect some kind magic to happen, perhaps it might not make sense at all, but at least by the book is better rather than barebones call to python VM with a raw call. Just run ambiguous code in side try-catch and hope to catch an exception.

This however depends on testing and validating the decision.

Edit your script in a separate text file, using an external editor. Then copy/paste into Blender’s text editor.