Sublime Forum

ST3 on_api_ready issue

#1

In 3010, on_api_ready() is iterating over sys.modules.values() directly (sublime_plugin.py:133). If a plugin does something like an import inside its plugin_loaded function, ST will bail with a RuntimeError (“dictionary changed size during iteration”). It might be better to capture modules.values() into a list before iterating to guard against that?

0 Likes

#2

I am curious about how you are using on_api_read in your plugin. I was looking for something like that when I started porting PC because I needed to check the version of PC to determine what import code to run.

Would it solve your problem if sublime.version(), sublime.arch() and sublime.platform() were available always? I don’t know if that is possible, but it would certainly make some of my import code a little cleaner.

0 Likes

#3

here’s what i’m doing:

try:
    import py3modules
else ImportError:
    import py2.6modules

def _import_modules():
    blah = sublime.blah # we have sublime
    # run all my imports here that need sublime avaialble

if not sublime.version():
    _import_modules()
def plugin_loaded():
    sublime.set_timeout_async(_import_modules)
0 Likes

#4

jburnett: Will fix for the next build

wbond: I’ll modify the next build so that sublime.version() and friends can be called at any time

0 Likes