--- /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 4A82E431FBC\r
+ for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 11:28:27 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.422\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.422 tagged_above=-999 required=5\r
+ tests=[AWL=-0.523, 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 qmHORpox0dLR for <notmuch@notmuchmail.org>;\r
+ Wed, 24 Feb 2010 11:28:26 -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 DD272431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 11:28:26 -0800 (PST)\r
+Received: from john-marshall.sflc.info ([216.27.154.200]\r
+ helo=wyzanski.hackervisions.org)\r
+ by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69)\r
+ (envelope-from <james@hackervisions.org>)\r
+ id 1NkMuF-0006dk-TC; Wed, 24 Feb 2010 14:28:24 -0500\r
+Date: Wed, 24 Feb 2010 14:28:16 -0500\r
+Message-ID: <878waiwi0f.wl%james@hackervisions.org>\r
+From: James Vasile <james@hackervisions.org>\r
+To: notmuch@notmuchmail.org\r
+In-Reply-To: <87vddnlxos.wl%james@hackervisions.org>\r
+References: <87vddnlxos.wl%james@hackervisions.org>\r
+X-Mailer: Wanderlust/2.15.6\r
+User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=)\r
+ APEL/10.7 Emacs/23.1 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)\r
+MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")\r
+Content-Type: text/plain; charset=US-ASCII\r
+Subject: Re: [notmuch] [PATCH] Calls to notmuch get queued and\r
+ executed asynchronously.\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: Wed, 24 Feb 2010 19:28:27 -0000\r
+\r
+Sleep between retrying asynchronous notmuch commands and check for\r
+notmuch-process before firing off a new one\r
+\r
+If the db is locked when notmuch tries to write to it, an error is\r
+reported to the client (in this case, notmuch.el). Instead of\r
+accepting that error, wait a small amount of time and then try again.\r
+\r
+Also, don't start multiple asynchronous processes.\r
+---\r
+ notmuch.el | 16 +++++++++++++---\r
+ 1 files changed, 13 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 7fc63e9..31e89b9 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -1402,9 +1402,14 @@ args is a list of arguments to notmuch. ex: (\"tag\" \"+list\"\r
+ \r
+ Calls to notmuch are queued and called asynchronously."\r
+ (setq notmuch-asynch-queue (append notmuch-asynch-queue (list args)))\r
+- (when (= (length notmuch-asynch-queue) 1)\r
++ (when (and (= (length notmuch-asynch-queue) 1)\r
++ (not (get-process "notmuch-process")))\r
+ (apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue))))\r
+- \r
++\r
++(defun notmuch-asynch-sleep-sentinel (process event)\r
++ "After we sleep, try a command from the notmuch queue"\r
++ (apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue)))\r
++\r
+ (defun notmuch-call-notmuch-process-asynch-sentinel (process event)\r
+ "Handle the exit of a notmuch asynch process.\r
+ \r
+@@ -1416,11 +1421,16 @@ command, try it again."\r
+ (if (= (process-exit-status process) 0)\r
+ (kill-buffer (buffer-name (process-buffer process)))\r
+ (if (search-forward "Unable to acquire database write lock" nil t)\r
+- (apply 'notmuch-call-notmuch-process-asynch (cdr (process-command process)))\r
++ (progn\r
++ (push (cdr (process-command process)) notmuch-asynch-queue)\r
++ (set-process-sentinel \r
++ (start-process "notmuch-sleep" nil "sleep" "3")\r
++ 'notmuch-asynch-sleep-sentinel))\r
+ (error (format "%s: %s" (join-string-list (process-command process))\r
+ (buffer-string))))))\r
+ (apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue)))\r
+ \r
++\r
+ (defun notmuch-call-notmuch-process (&rest args)\r
+ "Synchronously invoke \"notmuch\" with the given list of arguments.\r
+ \r
+-- \r
+1.6.3.3\r
+\r