I've coded a script to open files from a path written in the editor. I added a validation to avoid re-open files that are yet in the editor. For that, I'm using the function "notepad.getfiles", but, several times, the application keeps in a deadlock in the execution of that function, and I have no idea why.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's a very very long script, with several modules. I write here a summary of that, and write some code I think relevant.
First, the context:
Now: I'm using a version of Notepad++ "non-instalable" (I think 32-bits).
The version of PythonScript is "Python 2.7.6-notepad++ r2" with plugin version "1.0.6.0"
But I'm running over Windows 7 64 bits.
But, my script is not new; I mean, I've been using it over Windows XP 32 bits with an instalable version of Notepad++ with NO-ERROR (always run right). But recently, for distribution reasons, I made a package with a non-instalable version of Notepad++ and PythonScript yet installed (the reason: it's easier to install together from a customized executable like INNO SETUP with a non-instalable version of Notepad++ that is simple copy&paste files)
Since then the deadlock is happening, and after some hours puting traces on the script, I arrived the point getting the deadlock (notepad++ is like frozen): the function notepad.getfiles.
I write now some script points:
When startup, I register 3 callbacks of NOTIFICATION:
NOTIFICATION.READY
NOTIFICATION.FILEOPENED
NOTIFICATION.FILESAVED
There is no live-lock, no while error for counter not incrementing or similar.
The script works as following:
- Read lines from editor. Each line is a path for a file.
- Open the file.
But, in order to optimize and not to lose changes, before open the file, I check if the file is already open using "notepad.getfiles" and iterating the result. Well, the call to notepad.getfiles causes a deadlock.
Note: why the callbacks? Well, the reason is because I can open remote files using FTP, so I need to save the file caughting the save callback. The others are for comunication with an external application. But, this three callbacks never has made a deadlock. Only when the script is executed via PythonScript Plugin (menu, or shortcut).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
h_file = open('C:\\tmp\\trace.txt', 'a')
h_file.write('--This is a test 1a\n')
h_file.close()
lstFicheros = notepad.getFiles()
h_file = open('C:\\tmp\\trace.txt', 'a')
h_file.write('--This is a test 1b\n')
h_file.close()
fichAbierto = False
if len(lstFicheros) > 0:
i = 0
while (i < len(lstFicheros)) and (lstFicheros[i][0].upper() != pathFichero.upper()):
i += 1
fichAbierto = (i < len(lstFicheros))
return fichAbierto
The line "--This is a test 1b" is not written, only "--This is a test 1a" is in the trace.txt file.
Last edit: Vicente A 2014-09-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't reproduce this, even with 1.0.6 (I'm assuming you've checked that the about box says 1.0.7 now)
I've set callbacks for the notifications you mentioned, and tried doing more or less what you explained (opening a file based on the text in the document), but it all works fine.
I can only suggest that you try and strip down your code until you've got a reproducible case with some code that you can post. I can't see any reason in the code why getFiles should cause an issue.
Sorry I can't be more help.
Dave.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In solving another issue (https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/915d6d40/#b118) I may have stumbled upon the reason for this. See the link for a description, but I suspect this may be the problem here too, and would explain why I can't reproduce it.
The should be a new version shortly, so please try that and report back.
Thanks,
Dave.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello.
I've coded a script to open files from a path written in the editor. I added a validation to avoid re-open files that are yet in the editor. For that, I'm using the function "notepad.getfiles", but, several times, the application keeps in a deadlock in the execution of that function, and I have no idea why.
Can you post the code? I need to see what calls are being made, and what callbacks you're using.
Also, I presume you're using 1.0.7?
It's a very very long script, with several modules. I write here a summary of that, and write some code I think relevant.
First, the context:
Now: I'm using a version of Notepad++ "non-instalable" (I think 32-bits).
The version of PythonScript is "Python 2.7.6-notepad++ r2" with plugin version "1.0.6.0"
But I'm running over Windows 7 64 bits.
But, my script is not new; I mean, I've been using it over Windows XP 32 bits with an instalable version of Notepad++ with NO-ERROR (always run right). But recently, for distribution reasons, I made a package with a non-instalable version of Notepad++ and PythonScript yet installed (the reason: it's easier to install together from a customized executable like INNO SETUP with a non-instalable version of Notepad++ that is simple copy&paste files)
Since then the deadlock is happening, and after some hours puting traces on the script, I arrived the point getting the deadlock (notepad++ is like frozen): the function notepad.getfiles.
I write now some script points:
When startup, I register 3 callbacks of NOTIFICATION:
NOTIFICATION.READY
NOTIFICATION.FILEOPENED
NOTIFICATION.FILESAVED
There is no live-lock, no while error for counter not incrementing or similar.
The script works as following:
- Read lines from editor. Each line is a path for a file.
- Open the file.
But, in order to optimize and not to lose changes, before open the file, I check if the file is already open using "notepad.getfiles" and iterating the result. Well, the call to notepad.getfiles causes a deadlock.
Note: why the callbacks? Well, the reason is because I can open remote files using FTP, so I need to save the file caughting the save callback. The others are for comunication with an external application. But, this three callbacks never has made a deadlock. Only when the script is executed via PythonScript Plugin (menu, or shortcut).
The exact point where I've detected the deadlock:
def ficheroAbiertoConEditor(pathFichero):
The line "--This is a test 1b" is not written, only "--This is a test 1a" is in the trace.txt file.
Last edit: Vicente A 2014-09-24
I've updated plugin and notepad++ to the most recent version (this last with an official zip package from website), but the error continues :(.
I can't reproduce this, even with 1.0.6 (I'm assuming you've checked that the about box says 1.0.7 now)
I've set callbacks for the notifications you mentioned, and tried doing more or less what you explained (opening a file based on the text in the document), but it all works fine.
I can only suggest that you try and strip down your code until you've got a reproducible case with some code that you can post. I can't see any reason in the code why getFiles should cause an issue.
Sorry I can't be more help.
Dave.
In solving another issue (https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/915d6d40/#b118) I may have stumbled upon the reason for this. See the link for a description, but I suspect this may be the problem here too, and would explain why I can't reproduce it.
The should be a new version shortly, so please try that and report back.
Thanks,
Dave.
I've just updated PythonScript to version 1.0.8 and seems that now it works right !!
I read your post and I believe that the deadlock is due to what you wrote there (I think that callback deadlock).
However, I'm goint to try it for several days in different situations and then I promise to post you here details about what I'm doing.