Sublime Forum

My sublime_plugin.EventListener is not being initialized or called

#1

I have a large plugin called sublemacspro and one of the things I just added was an EventListener, one of several in my plugin. This one is used for handling/processing on_query_completions callbacks.

When I startup Sublime that aspect of my plugin doesn’t work. My code just plain old is not called.

However, if I make a trivial edit to the plugin file and save it, sublime reloads it, and it works just fine.

Meanwhile, all the other functionality of my plugin works fine at startup. It’s just this event listener that seems not to be included in the on_query_completions pipeline for some reason.

I have a print statement in the constructor. It’s not called during startup. It is called after I touch the file though.

Any thoughts?

0 Likes

#2

What is the code?

I suspect you’re running some code that is dependant on the API ST provides in __init__, but that is not available at the time the module is loaded and the event manager is initialized. I suggest taking a look into the console for exceptions.

0 Likes

#3

He said there was a print in his constructor, so he should have looked in the console.

So, you define plugin_loaded right?

0 Likes

#4

I do not define plugin_loaded. What is that? (gulp)

The thing to remember is that the plugin in general is working just fine. It’s just this event listener that’s not. If I remember, all I have to do is define the event listener right? Sublime comes along and instantiates it for me.

And of course the whole thing works if I do it after everything is started up.

My init function is accessing settings. Maybe that’s a mistake… I will check it out in a little while when I have a second.

Thanks for the advice.

0 Likes

#5

Live and learn.

Thanks for the plugin_loaded tip.

I was accessing the API before it was ready.

2 Likes

#6

Sorry, I wasn’t clear… :sweat: here’s more info (for somebody rereading this topic, I know you’ve already found the answer).

0 Likes