Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9586
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'socket': 0.04; 'handler.': 0.09; 'inclined': 0.09; 'locked': 0.09; 'loop.': 0.09; 'second.': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'simultaneous': 0.16; '16,': 0.16; 'this:': 0.16; 'received:209.85.210.174': 0.19; 'received :mail-iy0-f174.google.com': 0.19; 'variable': 0.21; 'seconds': 0.21; "aren't": 0.22; 'header:In-Reply-To:1': 0.22; 'frequent': 0.23; 'once.': 0.23; 'monitor': 0.23; 'moving': 0.25; 'sat,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'mapping': 0.29; 'toward': 0.29; 'lock': 0.30; 'queue': 0.30; 'this.': 0.31; 'shared': 0.32; 'chris': 0.32; 'does': 0.32; 'actually': 0.33; 'to:addr:python-list': 0.34; 'instead': 0.34; 'there': 0.34; 'be,': 0.35; 'conditions.': 0.35; 'option.': 0.35; 'actual': 0.35; 'data,': 0.35; 'requests': 0.35; 'connection': 0.36; 'file': 0.36; 'disk': 0.37; 'thread': 0.37; 'but': 0.37; 'could': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'problem.': 0.38; 'something': 0.38; 'two': 0.38; 'easier': 0.39; 'client': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; "i'd": 0.40; 'or,': 0.40; 'third': 0.40; 'your': 0.60; 'eliminate': 0.63; 'overall': 0.63; 'direct': 0.66; 'kept': 0.67; 'cameron': 0.67; 'subject:program': 0.67; 'connection,': 0.73; 'race': 0.73; 'habit': 0.84; 'timer': 0.84; 'viable': 0.84 |
| 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 :content-type; bh=SUb1C341abkhJzNVr/g1NA0yYLM7y3+QXkqfn18zxjw=; b=qI76L6rAKX6SalHPBmXC3aTm6zH0JI6F5M2ceGExSCu2Pn0O3OXpR3hT+I3oKyXKSi BxguFi6hfTS+y2W82UEw80luYNFfp3jIdiam21W/OkuKZbvxuciNC45x6uLaeOg8zdL3 QKBOmKUA22KJdVZlGnPfRTYMmc6jZ1u2DgD4c= |
| MIME-Version | 1.0 |
| In-Reply-To | <20110715223741.GA18822@cskk.homeip.net> |
| References | <ivq6ej$vpp$2@speranza.aioe.org> <20110715223741.GA18822@cskk.homeip.net> |
| Date | Sat, 16 Jul 2011 10:01:16 +1000 |
| Subject | Re: Looking for general advice on complex program |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1093.1310774479.1164.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1310774479 news.xs4all.nl 23878 [2001:888:2000:d::a6]:56255 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:9586 |
Show key headers only | View raw
On Sat, Jul 16, 2011 at 8:37 AM, Cameron Simpson <cs@zip.com.au> wrote: > There are two approaches to this. > You can create a file while your umask is 0777... [or] > My personal habit is to make a directory for the lock Both viable options; I'd be inclined toward the second. Or, here's a third option. Instead of writing to a shared network drive, submit requests on a TCP socket direct to the monitor program. Spin off a thread that does this: * Wait for incoming socket connection * Set overall cutoff timer; if (say) 2 seconds pass, kill the connection * Authenticate the client (if applicable) * Accept the update data, sanitize if necessary * Write the file to disk * Notify the XManager * Loop. Do all this on *one thread* and then you eliminate all race conditions. Good use of a TCP listen queue and the cutoff timer will mean that applications aren't actually kept waiting, but they're still rigidly locked into a queue - depending on how frequent your updates are, this could be a problem. If you need simultaneous updates, spin off a new thread for each socket connection, and then use something simple like a mapping of file name to semaphore to ensure no two try to update the same file at once. By moving the actual file read/writes to a single computer, you simplify the task of notifying the parent. In fact, if there's only one process that needs to be made aware of the change, the job's even easier - all you need to do is change a variable or call a method or whatever it be, right there in the socket handler. Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Looking for general advice on complex program Josh English <Joshua.R.English@gmail.com> - 2011-07-15 12:47 -0700
Re: Looking for general advice on complex program Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-15 16:03 -0400
Re: Looking for general advice on complex program Cameron Simpson <cs@zip.com.au> - 2011-07-16 08:37 +1000
Re: Looking for general advice on complex program Chris Angelico <rosuav@gmail.com> - 2011-07-16 10:01 +1000
Re: Looking for general advice on complex program geremy condra <debatem1@gmail.com> - 2011-07-16 14:08 -0400
csiph-web