Monitoring Feature not updating "automatically"
-
I was very glad to see the new Monitoring feature be added to Notepad++ 6.9.2.
I created a simple program that writes to a file, flushes, waits 500 ms, then repeats. I did this so I could see the refresh rate of this new tool.
It was not very impressive. After I initially opened the file it just stayed stationary. But it does change anytime the file gets focus the explorer window (if I deselected and reselected Notepad++ updates the file, but only then).
I am on Windows 10 Enterprise N x64 Version 1511 Build 10586.318
-
A lot of this has to due with the underlying OS and how it buffers file writes. I wrote a quick Python 2.7 script as follows:
import random import time import os with open("file.log", 'w') as f: while True: for i in range(100): f.write("Let's write some data " + str(random.randint(0,100)) + "\n") f.flush() os.fsync(f.fileno()) # This is important time.sleep(0.5)
Flushing does not necessarily write the contents to the disk. The important thing to note here is the call to
os.fsync(f.fileno())
. This will force the file to be written to disk and cause Notepad++ to actually pick up on the changes. -
I must be missing something here. I open cmd.exe and do ping -t 127.0.0.1 > out.txt. I launch Notepad++, open out.txt, and turn on Monitoring. The content just stays static. I open the same file periodically in regular notepad and, as one expects, it reflects the updated content each time. Cygwin’s tail -f also works fine.
-
That’s really odd. It’s doing the same for me…apparently it isn’t quite working completely yet :(
-
I also have the same behaviour, even on NPP7
-
Hello Bryan, dail and All,
AS for me, on my old XP SP3 configuration, your exact test, Bryan is working fine !!
-
I opened N++, in a full screen window
-
Then, I opened a classical DOS window, not in full screen size
-
If I type the command
ping -t 127.0.0.1
, my XP system answers, every second about, the message "Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128 ( in French ! ) -
So, I start, again, this command
ping -t 127.0.0.1 > out.txt
, with the file redirection -
Then, I opened the out.txt file in N++ and set the option View - Monitoring (tail -f)
-
After a couple of seconds, I saw the repeated message, as above, and I could notice that the line numbers were increasing, each second about, as expected :-))
Moreover, after putting, again, the DOS window in the foreground, in order to both see the N++ editor window and the DOS window, I hit, several times, the combination
CTRL + Attn
. As expected, the statistics were displayed, as soon as I used this shortcut, at the bottom of the N++ window of the current file out.txt !I don’t know what’s happening on your W7, W8 or W10 systems, on this matter ? Or, may be, this occurs, only, on X64 configurations ?
Here is, below, my Debug Info :
Notepad++ v7 (32-bit) Build time : Sep 1 2016 - 02:21:07 Path : C:\_700\notepad++.exe Admin mode : OFF Local Conf mode : ON OS : Windows XP Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll PluginManager.dll
Best Regards,
guy038
-
-
Hey,
Here`s the same behavior on java execution inside Eclipse with stdout redirected to a file. I’m using x64 Win7. Cygwin also tailing -f normally.
Must be someway to force the OS to flush?
-
I’m having the same problem: I enable monitoring of a file and write a line to the file from another program, it doesn’t get updated. But if I right-click on the tab and choose “Reload” then it loads the new line, and it also happens if I view the file in another program (e.g. FAR manager’s file viewer).
-
Same thing here… nothing happens when monitoring is activated on a file. Any hints on what is happening?
-
afaik, npp does not actively poll a file for its current state, instead it is using the windows event system to get informed when a file has been updated.
This technique has several advantages like
no ressources will be wasted while monitoring files, you can monitor many files without having
impact on the editor itself etc… but, obviously, has also a disadvantage, that is that the windows
event system doesn’t receive update information on files which aren’t updated in the “correct way” .
The “correct way” means, an application needs to flush the changes or close the file after writing
in order to generate such events.A simple example using the python script plugin.
Let’s assume you want to monitor a file C:\test_monitoring. Let’s do the the following
We create the file by usingf = open(r'C:\test_monitoring','w')
now let’s open the tile in npp and press monitoring button you should the the following
ok, let’s try to write something to the file like
f.write('this is a test')
and you will see that npp doesn’t get informed about the update.
but once the application which updated the file does a flush or close on that file like
f.flush() f.close()
the windows event system recognizes this and send the event to npp
As said, simple example because it gets even more complicated when the file to be monitored
is on the network or on an external usb disc or drive.Cheers
Claudia