-
Notifications
You must be signed in to change notification settings - Fork 17
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
File Reload of natlink should restart the whole python "subsystem" #28
Comments
At line 200, the reloadPython is performed, I think this is the function that is called when the File, Reload button is pressed in the Messages window. It would be nice, when the whole python "subsystem" is closed down and restarted, so all underlying modules are also refreshed (reloaded) after changes. Hope this is possible to realize at some time. |
If this were to be implemented please read the following #129 (comment) as it has implications for restarting the Python subsystem. |
This is what the Reload button is supposed to do, right? I could look into fixing it. |
That's my understanding, it's meant to reload the the interpreter. |
All right then. Looks like a job for me.
…On Sat, 08 Jun 2024 12:56:20 -0700 LexiconCode ***@***.***> wrote:
> This is what the Reload button is supposed to do, right? I could look into fixing it.
That's my understanding, it's meant to reload the the interpreter.
--
Reply to this email directly or view it on GitHub:
#28 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
Okay, I've looked into this now.
The reload button is broken because it only reloads the 'natlinkcore' module. This newer module is not a replacement for the old 'natlinkmain' module, which the button used to reload, so it doesn't work right. In Natlink 5, pressing reload should result in the re-running of the 'natlinkcore' loader. I'll submit a pull request to address this issue.
|
Could it reload the full pyrhon interpreter? |
Yes, that should be possible. That is what the button used to do, at least theoretically. According to the log, it was changed to only reload 'natlinkmain' in October, 2019. (See commit d05715c.) It looks like this was a workaround.
…On Mon, 01 Jul 2024 07:36:36 -0700 LexiconCode ***@***.***> wrote:
Could it reload the full pyrhon interpreter?
--
Reply to this email directly or view it on GitHub:
#28 (comment)
You are receiving this because you were assigned.
Message ID: ***@***.***>
|
This reverts commit d05715c. Re: dictation-toolbox#28.
I managed to get the button to reload the interpreter. However, PyWin32 does not support this sort of reinitialisation. Its COM component raises errors that prevent most of my command modules from loading. This is an old issue, apparently, which probably won't be fixed.
Since most of us rely on PyWin32, the best Natlink's reload button can do reload Natlink's Python code and any user modules.
|
My proposal from Wednesday to use Natlink exclusively in normal Python processes (#198), if realised, has implications for the reload button. The simplest way to deal with it, I think, is to add a new callback to be used in 'natlinkcore':
def onReload():
# Reload user modules.
# ...
natlink.setReloadCallback(onReload)
|
The issue I rediscovered above with interpreter reinitialization has implications for Natlink's Python thread support. If the reload button cannot practically reinitialize the interpreter, thread support might just as well be enabled by default. |
Why not do so? Honestly, I never saw any difference in the working of Natlink with or without the threading option. If you think on is OK, just put the default on!! |
All right then, that can be changed in a future release. I would suggest major version 6 include that and my implementation of #198, if it works as expected.
It looks like thread support was only ever optional because of the interpreter reinitialization. The effect of it being disabled is noticeable only if another thread is started from Python.
…On Mon, 19 Aug 2024 00:24:12 -0700 Quintijn Hoogenboom ***@***.***> wrote:
Why not do so? Honestly, I never saw any difference in the working of Natlink with or without the threading option. If you think on is OK, just put the default on!!
--
Reply to this email directly or view it on GitHub:
#28 (comment)
You are receiving this because you were assigned.
Message ID: ***@***.***>
|
Re: dictation-toolbox#213. The new function is setMessageWindow(). I have documented it in the NatlinkSource/natlink.txt file. It is now necessary to call this function with a Python callback to enable the message window. The default callback will soon reside in the natlinkcore code and be set from appsupp.cpp. Since it is related, this changeset includes modifications to the message window's File>Reload logic, re: dictation-toolbox#28. The default callback will do a narrower reloading of user modules.
No description provided.
The text was updated successfully, but these errors were encountered: