Home Download Buy Blog Forum Support

ST2 crashes after an os.system call

ST2 crashes after an os.system call

Postby pierre on Sun Jan 27, 2013 7:21 pm

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
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm

Re: ST2 crashes after an os.system call

Postby FichteFoll on Sun Jan 27, 2013 7:29 pm

Try using the subprocess module instead.
FichteFoll
 
Posts: 388
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: ST2 crashes after an os.system call

Postby pierre on Sun Jan 27, 2013 10:32 pm

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?
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm

Re: ST2 crashes after an os.system call

Postby FichteFoll on Mon Jan 28, 2013 2:24 pm

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.
FichteFoll
 
Posts: 388
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests