Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'own.': 0.03; '2.7': 0.04; '(using': 0.05; 'think,': 0.05; 'mess': 0.07; 'wxpython': 0.07; 'python': 0.08; 'rolling': 0.09; 'to:addr:comp.lang.python': 0.09; 'url:packages': 0.09; 'gui': 0.13; 'wrote:': 0.15; 'intervals.': 0.16; 'threading': 0.16; 'timed': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'level,': 0.19; 'tree': 0.19; 'cc:2**0': 0.21; 'file,': 0.22; 'maybe': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'here?': 0.23; 'unsure': 0.23; 'monitor': 0.23; 'modules': 0.25; 'xml': 0.25; "i'm": 0.27; 'do,': 0.28; 'fri,': 0.28; 'message- id:@mail.gmail.com': 0.28; 'constant': 0.29; 'problem': 0.29; 'code,': 0.29; 'cc:addr:python.org': 0.30; 'classes': 0.30; 'not.': 0.30; 'threads': 0.30; 'class': 0.31; 'expanding': 0.31; 'separate': 0.31; 'changes': 0.31; 'shared': 0.32; 'file.': 0.32; "i've": 0.33; 'here,': 0.35; 'regular': 0.36; 'file': 0.36; 'url:python': 0.37; 'trouble': 0.37; 'thread': 0.37; 'but': 0.37; 'several': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'problem.': 0.38; 'think': 0.38; 'went': 0.39; 'needed.': 0.40; 'received:209': 0.40; "i'd": 0.40; 'stop': 0.61; 'show': 0.67; 'subject:program': 0.67; 'exact': 0.69; 'periodically': 0.73; 'node': 0.84; 'paused,': 0.84; 'alerted': 0.91; 'drive.': 0.91; 'need,': 0.91; 'recurring': 0.91; 'writing.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=WjmoHL+J1uGNeVRdZFNsCbdWYKMfyqcqwn946xDwO7Q=; b=S/6ndRZDdCCthINmwKGQ+P9PUHtB8USK32q8HGAselfHFPsBMRfrGnrTTf51uZhs6m yoci9Y093Mg7F7pDsANw5uZSlntj096L76hlOb1/cN5ASmrXQDx5Z8jhhc44IB67vneQ k6IMsvBK4lr6d6svLPUxbttmX+xWlrb95bGek= MIME-Version: 1.0 In-Reply-To: <4ab6df51-ec86-4144-98a6-71d372f09f74@glegroupsg2000goo.googlegroups.com> References: <4ab6df51-ec86-4144-98a6-71d372f09f74@glegroupsg2000goo.googlegroups.com> Date: Sat, 16 Jul 2011 14:08:49 -0400 Subject: Re: Looking for general advice on complex program From: geremy condra To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310839733 news.xs4all.nl 23902 [2001:888:2000:d::a6]:41928 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9639 On Fri, Jul 15, 2011 at 3:47 PM, Josh English 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 read= s each XML file into a tree (using ElementTree). The XManager class can rea= d 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 unders= tand 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 const= ant 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 bei= ng show modally or not. > > So, am I on the right track here? I'd try watchdog[0] before I went to the trouble of rolling my own. Geremy Condra [0]: http://packages.python.org/watchdog/