Sublime Forum

ST2 crashes after an os.system call

#1

I’m trying to use asymptote to draw some pictures
(Mac OSX.8.2, ST build 2220)

asy is installed in /usr/local/bin and works fine from
the command line. If I run ‘asy file_name.asy’ from the
command line I get a nice file_name.eps picture.

However, the following code inside a plugin
f = self.view.file_name()
os.system(’/usr/local/bin/asy ’ + f)
crashes ST2 consistently. Have you ever encountered
this kind of behaviour? asy takes almost a second to
finish, but apart from that, why ST2 should crash?

Piero

0 Likes

#2

Try using the subprocess module instead.

0 Likes

#3

Thanks for the suggestion. subprocess also crashes.
Never mind. Still, I am curious about the root of the
problem, is it the fact that the system call takes
really long to finish?

0 Likes

#4

Depends on how “crashing” works on OSX. Usually the “Plugin takes to long to whatever” message is displayed when run inside an event listener. If you have a command it’s probably different.
If you think that the call takes to long, either run it asynchronously with subprocess.Popen() and check periodically with sublime.set_timeout() or run it in a new thread using thread or threading module.

You could also try sublime_plugin.run_timed_function(callback, "plugin name", "event/function name", timeout_in_floating_seconds) and see if it shows the msg.

0 Likes