Looking for general advice on complex program
debatem1 at gmail.com
Sat Jul 16 14:08:49 EDT 2011
On Fri, Jul 15, 2011 at 3:47 PM, Josh English
<Joshua.R.English at gmail.com> wrote:
> Maybe not to the gurus here, but for me, this is a complex problem and I want to make sure I understand the real problem.
> All of this is in Python 2.7 and wxPython
> I have several XML files on a shared drive.
> I have applications on other machines that need to access this XML file.
> These applications need to read and write to this file.
> These applications need to a) be alerted to a file change, or b) monitor the file for changes and regular intervals.
> In my code, I have XManager classes (using a Singleton pattern) that reads each XML file into a tree (using ElementTree). The XManager class can read the file, make changes to the tree, and write the file as needed.
> Now I'm expanding to the multiple application level, and I think I understand what I need to do, and I'm unsure about the exact processes.
> I've been trying to have the XManagers check periodically if the XML file they monitor has changed. Since I don't want to mess up the GUI with constant hanging, I think I can use the thread or threading modules to create a recurring timed check, and then I need a separate check to see if the file is in use before reading or writing.
> I also need, I think, to have a way to check if the GUI is editing a node before the XManager reads the file, so the thread needs to be interrupted, or paused, because I don't know if threads would stop if a wxDialog is being show modally or not.
> So, am I on the right track here?
I'd try watchdog before I went to the trouble of rolling my own.
More information about the Python-list