--- /dev/null
+Return-Path: <james@hackervisions.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id A7333431FBF\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Feb 2010 04:53:43 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.05\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.05 tagged_above=-999 required=5 tests=[AWL=-0.151,\r
+ BAYES_50=0.001, RDNS_DYNAMIC=0.1] autolearn=no\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id tOtQZsqAukzj for <notmuch@notmuchmail.org>;\r
+ Fri, 26 Feb 2010 04:53:42 -0800 (PST)\r
+Received: from hackervisions.org (67-207-143-141.slicehost.net\r
+ [67.207.143.141])\r
+ by olra.theworths.org (Postfix) with ESMTP id C7D73431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Feb 2010 04:53:42 -0800 (PST)\r
+Received: from ool-18bd392a.dyn.optonline.net ([24.189.57.42] helo=localhost)\r
+ by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69)\r
+ (envelope-from <james@hackervisions.org>) id 1NkzhK-0003o1-6b\r
+ for notmuch@notmuchmail.org; Fri, 26 Feb 2010 07:53:38 -0500\r
+From: James Vasile <james@hackervisions.org>\r
+To: notmuch@notmuchmail.org\r
+Date: Fri, 26 Feb 2010 07:53:29 -0500\r
+Message-ID: <87pr3sw43a.fsf@hackervisions.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Subject: [notmuch] [PATCH] Add shell script notmuch-retry\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 26 Feb 2010 12:53:43 -0000\r
+\r
+It occurs to me that having generic ability to tell notmuch to retry\r
+until the DB isn't locked might useful. So I put the functionality in a\r
+script that can sit between notmuch and various clients. It will\r
+simplify my emacs setup, and improve it since emacs's handling of\r
+asynchronous processes isn't great.\r
+\r
+This script calls notmuch and passes on all commandline arguments. If\r
+DB is locked, keep trying notmuch until the DB isn't locked. Notmuch's\r
+stdout and stderr go to stdout and stderr. Returns notmuch's return\r
+code.\r
+\r
+Maybe this retry loop should be put in notmuch itself?\r
+\r
+---\r
+ notmuch-retry | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 51 insertions(+), 0 deletions(-)\r
+ create mode 100755 notmuch-retry\r
+\r
+diff --git a/notmuch-retry b/notmuch-retry\r
+new file mode 100755\r
+index 0000000..2d7fcbc\r
+--- /dev/null\r
++++ b/notmuch-retry\r
+@@ -0,0 +1,51 @@\r
++#!/bin/bash\r
++#\r
++# notmuch-retry --- call notmuch and retry if DB is locked\r
++#\r
++# Calls notmuch and passes on all commandline arguments. If DB is\r
++# locked, keep trying notmuch until the DB isn't locked. Notmuch's\r
++# stdout and stderr go to stdout and stderr. Returns notmuch's return\r
++# code.\r
++#\r
++# Copyright 2010 James Vasile\r
++#\r
++# This is free software: you can redistribute it and/or modify it\r
++# under the terms of the GNU General Public License as published by\r
++# the Free Software Foundation, either version 3 of the License, or\r
++# (at your option) any later version.\r
++#\r
++# This software is distributed in the hope that it will be useful, but\r
++# WITHOUT ANY WARRANTY; without even the implied warranty of\r
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++# General Public License for more details.\r
++#\r
++# You should have received a copy of the GNU General Public License\r
++# along with this software. If not, see\r
++# <http://www.gnu.org/licenses/>.\r
++#\r
++# Authors: James Vasile <james@hackervisions.org>\r
++\r
++bin=`which notmuch`\r
++\r
++notmuch_retry () { \r
++ regex="already locked"\r
++ while [ 1 -gt 0 ]; do\r
++ $bin $@ 2>$err\r
++ retcode=$?\r
++ result=$(<$err)\r
++ if [[ $result =~ $regex ]]; then\r
++ sleep 2.5\r
++ else\r
++ if [ -n "$result" ]; then\r
++ echo $result >&2\r
++ fi\r
++ return $retcode\r
++ fi\r
++ done\r
++}\r
++\r
++err=$(mktemp)\r
++notmuch_retry $@\r
++retcode=$?\r
++rm $err\r
++exit $retcode\r
+-- \r
+1.6.3.3\r
+\r