[PyQt] graphical file tail

Eric Frederich eric.frederich at gmail.com
Tue Jun 25 15:08:47 BST 2013


Calling t.wait() directly after t.foo() seems to have solved the problem.
I don't need to pass in self to the QTextBrowser constructor because I
added it to a layout and set the layout on the TailWidget so it
happens implicitly.

So, if I put this t.wait() call right after the t.foo() call is there
anything else wrong with my code that I should know about?

Thanks for your help.

On Mon, Jun 24, 2013 at 7:25 PM, John Lee <jjl at pobox.com> wrote:
> On Mon, 24 Jun 2013, Eric Frederich wrote:
>
>> I'm trying to tail several files graphically.
>> I have been trying to find a way to tail several files in a GUI
>> without much luck at all.
>> I get errors from tail saying broken pipe.
>> I get PyQt errors saying underlying C++ objects have been destroyed.
>> I get other Qt errors saying that threads are still running when the
>> application exits
>> etc....
>>
>> The implementation posted below seems to suffer from the following errors.
>> Not all the time.  It depends.
>>
>> QThread: Destroyed while thread is still running
>> QWaitCondition::wakeAll(): mutex lock failure:
>
>
> You're not calling .wait on the threads, and you probably want to give e.g.
> your QObjects a parent where you can, so that Qt manages the lifetime of the
> wrapped C++ objects (e.g. pass in self to the parent arg of the QTextBrowser
> constructor).
>
> But, I recommend doing it a different way: I find event-based code easier to
> think about than threads.  So, if you can use Qt5, you might want to do away
> with the threads and the tail subprocess and replace them with
> QFileSystemWatcher.  Use event-based code instead of the threads (I'm not
> talking about Qt events, I just mean hook up to the signals that that class
> emits and process a little input at a time so as to avoid blocking the UI,
> using QTimer where needed).  I say Qt5 because Qt4 isn't very friendly to
> this way of working since it uses threads in the implementation of
> QFileSystemWatcher.
>
> Caveat: QFileSystemWatcher still has its problems, but the ones discussed at
> the URL below are more convenience issues than fundamental problems: I just
> found I had to experiment a bit to see when the different signals got
> emitted.
>
> http://blog.rburchell.com/2012/03/qt-51-aka-when-qfilesystemwatcher-might.html
>
> Caveat #2: I imagine QFileSystemWatcher does not support filesystems like
> NFS, at least on Linux kernels with inotify support (but don't take my word
> for it, check the source).
>
>
> John
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list