<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Interprocess Synchronization in Python/Linux</title>
	<atom:link href="http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/</link>
	<description>Electronic Music, Programming</description>
	<lastBuildDate>Sun, 05 Sep 2010 14:55:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: will</title>
		<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/comment-page-1/#comment-623</link>
		<dc:creator>will</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:05:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.soundc.de/blog/?p=103#comment-623</guid>
		<description>There&#039;s several ways to accomplish what you want using a DB and there are performance and scalability benefits to doing so (what happens if you want to have more than one box processing your fifo?)

The simplest, and most compatible method, is to use a separate table with one row in it as the lock, simply update that row as the first operation in your transaction and all other accesses will serialize behind it. Or you could just &#039;lock table blah in exclusive mode&#039; dunno whether that&#039;s supported in all DB servers though. You can get smarter too, but it&#039;s only worth it if you were going to do a lot more work in the txn and wanted to maintain parallelism.</description>
		<content:encoded><![CDATA[<p>There&#8217;s several ways to accomplish what you want using a DB and there are performance and scalability benefits to doing so (what happens if you want to have more than one box processing your fifo?)</p>
<p>The simplest, and most compatible method, is to use a separate table with one row in it as the lock, simply update that row as the first operation in your transaction and all other accesses will serialize behind it. Or you could just &#8216;lock table blah in exclusive mode&#8217; dunno whether that&#8217;s supported in all DB servers though. You can get smarter too, but it&#8217;s only worth it if you were going to do a lot more work in the txn and wanted to maintain parallelism.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/comment-page-1/#comment-61</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 21 Oct 2008 14:22:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.soundc.de/blog/?p=103#comment-61</guid>
		<description>Thanks a lot for your comments Hongli and Marius.  I will look deeper into Optimisitic Concurrency Control and ACID transactions.  At first glance, I don&#039;t think I can employ any these techniques.  This is basically because I need to do something very specific with the database table.  Perhaps I didn&#039;t explain it clearly in my post.

All instances of my cgi script perform a read operation followed by a delete operation.  Essentially, my script reads the top row from the database. Right after the information is retrieved that particular row is deleted.  In other words, I am using my database as a FIFO buffer.  Now if several instances of my scripts are running, more than one of them could access the first row (read it), thereby letting two different processes fetch the same element from a FIFO.  One of them then fails with the deletion operation.  The whole idea behind this locking mechanism was to avoid this.  All instances of my script should always fetch a different item.

I will explore these techniques further to see if they could help me better solve my problem.</description>
		<content:encoded><![CDATA[<p>Thanks a lot for your comments Hongli and Marius.  I will look deeper into Optimisitic Concurrency Control and ACID transactions.  At first glance, I don&#8217;t think I can employ any these techniques.  This is basically because I need to do something very specific with the database table.  Perhaps I didn&#8217;t explain it clearly in my post.</p>
<p>All instances of my cgi script perform a read operation followed by a delete operation.  Essentially, my script reads the top row from the database. Right after the information is retrieved that particular row is deleted.  In other words, I am using my database as a FIFO buffer.  Now if several instances of my scripts are running, more than one of them could access the first row (read it), thereby letting two different processes fetch the same element from a FIFO.  One of them then fails with the deletion operation.  The whole idea behind this locking mechanism was to avoid this.  All instances of my script should always fetch a different item.</p>
<p>I will explore these techniques further to see if they could help me better solve my problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hongli Lai</title>
		<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/comment-page-1/#comment-59</link>
		<dc:creator>Hongli Lai</dc:creator>
		<pubDate>Tue, 21 Oct 2008 11:06:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.soundc.de/blog/?p=103#comment-59</guid>
		<description>Have you considered not synchronizing them, and using optimistic concurrency control instead? That is, use transactions, and put correct constraints in your schema to ensure that it will stay consistent. Then run your transaction, and after the transaction, check whether the desired effect was achieved (which could be just checking whether no database constraint violation occurred), and if not, restart the transaction. Wikipedia has more information on optimistic concurrency control.</description>
		<content:encoded><![CDATA[<p>Have you considered not synchronizing them, and using optimistic concurrency control instead? That is, use transactions, and put correct constraints in your schema to ensure that it will stay consistent. Then run your transaction, and after the transaction, check whether the desired effect was achieved (which could be just checking whether no database constraint violation occurred), and if not, restart the transaction. Wikipedia has more information on optimistic concurrency control.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marius Gedminas</title>
		<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/comment-page-1/#comment-58</link>
		<dc:creator>Marius Gedminas</dc:creator>
		<pubDate>Tue, 21 Oct 2008 08:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.soundc.de/blog/?p=103#comment-58</guid>
		<description>Generally databases have ACID transactions for this sort of thing.</description>
		<content:encoded><![CDATA[<p>Generally databases have ACID transactions for this sort of thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
