Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"force natlink to reload all grammars" occasionally causes errors #77

Open
djr7C4 opened this issue Oct 28, 2014 · 10 comments
Open

"force natlink to reload all grammars" occasionally causes errors #77

djr7C4 opened this issue Oct 28, 2014 · 10 comments

Comments

@djr7C4
Copy link
Contributor

djr7C4 commented Oct 28, 2014

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).

@calmofthestorm
Copy link
Member

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

@djr7C4
Copy link
Contributor Author

djr7C4 commented Oct 28, 2014

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 notifications@github.com 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:
#77 (comment)

@calmofthestorm
Copy link
Member

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.

@djr7C4
Copy link
Contributor Author

djr7C4 commented Oct 28, 2014

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 notifications@github.com 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:
#77 (comment)

@calmofthestorm
Copy link
Member

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

@djr7C4
Copy link
Contributor Author

djr7C4 commented Oct 28, 2014

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
Copy link
Contributor Author

djr7C4 commented Apr 3, 2015

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.

@Yorgg
Copy link

Yorgg commented Mar 24, 2018

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

@djr7C4
Copy link
Contributor Author

djr7C4 commented Mar 24, 2018 via email

@Haggr
Copy link

Haggr commented Nov 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants