aenea icon indicating copy to clipboard operation
aenea copied to clipboard

"force natlink to reload all grammars" occasionally causes errors

Open djr7C4 opened this issue 11 years ago • 10 comments

Specifically, sometimes modules used in grammars are set to None after running this command but this does not always happen. This causes obvious problems when grammars attempt to refer to those modules...

Presumeably, this command sometimes unloads modules it shouldn't (modules imported from grammars are unloaded and then reloaded in the implementation). It's also possible that it might reload things in the wrong order which could also cause problems (this seems like the most likely cause).

djr7C4 avatar Oct 28 '14 00:10 djr7C4

I've run into this too, and am not sure how to fix it. The only work-around I know about is restarting Dragon.

calmofthestorm avatar Oct 28 '14 03:10 calmofthestorm

Likewise.

Have you been able to reproduce this error reliably? I haven't and this makes it hard to fix...

On October 27, 2014 11:00:20 PM EDT, Alex Roper [email protected] wrote:

I've run into this too, and am not sure how to fix it. The only work-around I know about is restarting Dragon.


Reply to this email directly or view it on GitHub: https://github.com/dictation-toolbox/aenea/issues/77#issuecomment-60703563

djr7C4 avatar Oct 28 '14 03:10 djr7C4

Afraid not, but I don't reload frequently in regular use, only when developing, wihch I haven't done much of since you changed how reloads work. Before that change it was easy to reproduce, just import a module that's not a grammar.

calmofthestorm avatar Oct 28 '14 03:10 calmofthestorm

Are you saying this was already an issue before the reload change I made? I never noticed it before that.

On October 27, 2014 11:17:23 PM EDT, Alex Roper [email protected] wrote:

Afraid not, but I don't reload frequently in regular use, only when developing, wihch I haven't done much of since you changed how reloads work. Before that change it was easy to reproduce, just import a module that's not a grammar.


Reply to this email directly or view it on GitHub: https://github.com/dictation-toolbox/aenea/issues/77#issuecomment-60704637

djr7C4 avatar Oct 28 '14 03:10 djr7C4

Yeah your change went from never working to sometimes working:-)

calmofthestorm avatar Oct 28 '14 03:10 calmofthestorm

Interesting! At least we are making progress!

I figure the ordering of sys.modules might differ from run to run so I've changed the code on my local copy to always sort it before doing anything. We'll see if that makes things more predictable...

djr7C4 avatar Oct 28 '14 03:10 djr7C4

Is anyone still encountering this issue? I have not had it happen for some time now so perhaps it was fixed by some other change.

djr7C4 avatar Apr 03 '15 22:04 djr7C4

I am encountering this issue. I need to restart DNS each time i update the files :(

Yorgg avatar Mar 24 '18 06:03 Yorgg

I'm sure a pull request would be welcome :-)

On Fri, Mar 23, 2018, 11:15 PM Jon Yorg [email protected] wrote:

I am encountering this issue. I need to restart dragon each time i update the files :(

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dictation-toolbox/aenea/issues/77#issuecomment-375850129, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoHSP0_cJDTm1qbQ6lP3iEHdhyRlp7Zks5theR9gaJpZM4Czp1U .

djr7C4 avatar Mar 24 '18 09:03 djr7C4

I encountered the error as well and made a makeshift fix. I don't think the solution is worth a pull request but I can elaborate on the problem to make it easy to fix later on.

I first encountered the problem when I started to use _multiedit.py. The unload function was causing the problem. Long story short, this grammar deals with the vocabulary grammar to inhibit/uninhibit some vocabularies. It calls on to uninhibit them while unloading. Not sure how that works but the vocabulary grammar is multiedit's wrapper. I don't even know what wrapper means in this case. The problem occurs because the vocabulary grammar is the first to unload. Thus, when multiedit attemps to unload, because the "wrapper" is not loaded, it raises an error. The traceback is at the bottom.

My dumbass solution was to just go to the unloadEverything function in core/natlinkmain.py and hardcode into it that it should unload the grammar named "_vocabulary" the last.

Error calling _multiedit.unload
Traceback (most recent call last):
  File "C:\Natlink\Natlink\MacroSystem\core\natlinkmain.py", line 360, in safelyCall
    apply(func, [])
  File "C:\Natlink\Natlink\MacroSystem\_multiedit.py", line 339, in unload
    aenea.vocabulary.uninhibit_global_dynamic_vocabulary('multiedit', MULTIEDIT_TAGS)
  File "C:\Natlink\Natlink\MacroSystem\aenea\vocabulary.py", line 293, in uninhibit_global_dynamic_vocabulary
    uninhibit_global_dynamic_vocabulary(grammar_name, t)
  File "C:\Natlink\Natlink\MacroSystem\aenea\vocabulary.py", line 290, in uninhibit_global_dynamic_vocabulary
    _rebuild_lists('dynamic')
  File "C:\Natlink\Natlink\MacroSystem\aenea\vocabulary.py", line 162, in _rebuild_lists
    _global_list.clear()
  File "C:\Python27\lib\site-packages\dragonfly\grammar\list.py", line 272, in clear
    self._update(); return result
  File "C:\Python27\lib\site-packages\dragonfly\grammar\list.py", line 115, in _update
    self._grammar.update_list(self)
  File "C:\Python27\lib\site-packages\dragonfly\grammar\grammar_base.py", line 337, in update_list
    self._engine.update_list(lst, self)
  File "C:\Python27\lib\site-packages\dragonfly\engines\backend_natlink\engine.py", line 282, in update_list
    wrapper = self._get_grammar_wrapper(grammar)
  File "C:\Python27\lib\site-packages\dragonfly\engines\base\engine.py", line 191, in _get_grammar_wrapper
    raise EngineError("Grammar %s never loaded." % grammar)
EngineError: Grammar Grammar(vocabulary) never loaded.

Haggr avatar Nov 08 '20 17:11 Haggr