0
Not a bug

Sublime crashes after executing command which uses applescript to interact with it

Philipp Brumm 6 years ago • updated by Jon Skinner 6 years ago 0
Doing this in the console

import commands
commands.getoutput("osascript -e 'tell app \"Sublime Text 2\" to choose color'")

results in Sublime freezing and needing to be force-quit.

Answer

Answer
Not a bug
The command you're entering blocks the main thread while awaiting a reply from the main thread of the current process. By definition, this can't work.

In general, as commands entered via the console are run in the main thread of the Sublime Text process, there are many ways to cause harm to the process. The only alternative would be to run a sandboxed version of Python that couldn't interact with the system, which would not be desirable.

The above aside, you may be able to get the desired result running the command via a thread in a plugin. However, due to the way the Python Global Interpreter Lock works, I can't guarantee this will work without trying it.
Answer
Not a bug
The command you're entering blocks the main thread while awaiting a reply from the main thread of the current process. By definition, this can't work.

In general, as commands entered via the console are run in the main thread of the Sublime Text process, there are many ways to cause harm to the process. The only alternative would be to run a sandboxed version of Python that couldn't interact with the system, which would not be desirable.

The above aside, you may be able to get the desired result running the command via a thread in a plugin. However, due to the way the Python Global Interpreter Lock works, I can't guarantee this will work without trying it.