Saving a file in a big project locks up Sublime #37

Closed
bjnortier opened this Issue Oct 3, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@bjnortier
Contributor

bjnortier commented Oct 3, 2012

I have a fairly big project and every time I save a file, Sublime locks up for about 5 seconds. I have traced it to

sublime.set_timeout(completions.compile_source, 0)

in sublimerl_completion.py:

def on_post_save(self, view):
    ...
    class SublimErlThread(threading.Thread):
        def run(self):
            # compile
            sublime.set_timeout(completions.compile_source, 0) # 
            # trigger event to reload completions
            sublime.set_timeout(completions.generate_project_completions, 0)
    SublimErlThread().start()

https://github.com/ostinelli/SublimErl/blob/master/sublimerl_completion.py#L212

I believe it's because it takes about 5 seconds for rebar to compile the whole project. Interestingly, if I remove the sublime.set_timeout and just call

completions.compile_source()

then it's fine as it's not in the Sublime GUI thread, but I presume that's not thread-safe and set_timeout is used for a reason.

Using skip_deps=true when compiling would help, but it will still lock up the UI for a second or two.

If it could be kept in the separate thread and 'skip_deps=true' it would be great. I can create a pull request.

What is the reason for using set_timeout?

@ostinelli

This comment has been minimized.

Show comment
Hide comment
@ostinelli

ostinelli Oct 3, 2012

Owner

Hi Benjamin,

thank you for this feedback. I had to use set_timeout previously because some sublime methods are only available from the main thread, but I've done a major code refactoring that should have got rid of those.

So please go ahead and create the pull request.

Owner

ostinelli commented Oct 3, 2012

Hi Benjamin,

thank you for this feedback. I had to use set_timeout previously because some sublime methods are only available from the main thread, but I've done a major code refactoring that should have got rid of those.

So please go ahead and create the pull request.

@ostinelli

This comment has been minimized.

Show comment
Hide comment
@ostinelli

ostinelli Oct 5, 2012

Owner

Hi @bjnortier,

should I go ahead with this or wait for your pull request? :)

Owner

ostinelli commented Oct 5, 2012

Hi @bjnortier,

should I go ahead with this or wait for your pull request? :)

bjnortier added a commit to bjnortier/SublimErl that referenced this issue Oct 5, 2012

#37 Saving a large project doesn't lock up Sublime
When saving a file, "rebar compile" is run with 
skip_deps=true so that dependencies aren't 
recompiled. On on_post_save, set_timout is not 
used as it lock up the GUI thread.
@bjnortier

This comment has been minimized.

Show comment
Hide comment
@bjnortier

bjnortier Oct 5, 2012

Contributor

Created. I only changed the set_timeout calls in on_post_save, not the others as I was unsure about them

Contributor

bjnortier commented Oct 5, 2012

Created. I only changed the set_timeout calls in on_post_save, not the others as I was unsure about them

@ostinelli

This comment has been minimized.

Show comment
Hide comment
@ostinelli

ostinelli Oct 6, 2012

Owner

Thank you. Will review and merge asap.

Owner

ostinelli commented Oct 6, 2012

Thank you. Will review and merge asap.

@ostinelli ostinelli closed this Oct 6, 2012

ostinelli added a commit that referenced this issue Oct 8, 2012

#37 Saving a large project doesn't lock up Sublime
When saving a file, "rebar compile" is run with
skip_deps=true so that dependencies aren't
recompiled. On on_post_save, set_timout is not
used as it lock up the GUI thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment