Concurrency is trickyConcurrency may or may not be hard (I know people who disagree with me on that). But I am sure that it is tricky. As an illustration, I just fixed a DWiki concurrency bug that I first spotted in MyFirstCommentSpam. For simplicity, DWiki stores each comment as a file in a directory
hierarchy that mirrors the page's DWiki path; if you comment on the
DWiki page DWiki does this with code like this:
( This is perfectly ordinary code and I didn't think twice about
it. Except that there's a concurrency problem: if two (or more)
comments on the same page are posted at the same time, and this is the
first time the page has been commented on, they can race in this small
section. Both can see no directory, then start The truly reliable cure requires much more complicated code, because you cannot just do: try: os.makedirs(loc) except EnvironmentError, e: pass # ... do things The problem is that
The concurrency problem with the simple solution is not in my code,
it's in how Concurrency is tricky because it's easy to overlook cases. And it's not just your code that matters, it's also all the library routines or standard modules that your code depends on. And the authors may not have so much overlooked cases as considered them outside the specification. Sidebar: the concurrency safe makedirs()The trick is to modify
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |