emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 72c1954517 096/427: Block on connection until the


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 72c1954517 096/427: Block on connection until the output has flushed.
Date: Tue, 13 Dec 2022 02:59:31 -0500 (EST)

branch: elpa/emacsql
commit 72c195451754039c1086470ac686103cd3f79b81
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Block on connection until the output has flushed.
    
    This will enable the with-connection macro to work properly.
---
 emacsql.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/emacsql.el b/emacsql.el
index dddbe638f0..c746e4e276 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -91,6 +91,14 @@ This collection exists for cleanup purposes.")
   "Retrieve value from REF."
   (gethash t ref))
 
+(defun emacsql--flush (conn)
+  "Flush (and toss) any waiting output from CONN."
+  (emacsql--send conn ";\n.print EMACSQL")
+  (with-current-buffer (emacsql-buffer conn)
+    (cl-loop until (string-match-p "EMACSQL\n#" (buffer-string))
+             do (accept-process-output)))
+  (emacsql--clear conn))
+
 (cl-defun emacsql-connect (file &key log)
   "Open a connected to database stored in FILE.
 If FILE is nil use an in-memory database.
@@ -110,6 +118,7 @@ buffer. This is for debugging purposes."
       (when log
         (setf (emacsql-log conn) (generate-new-buffer "*emacsql-log*")))
       (prog1 conn
+        (emacsql--flush conn)
         (push (cons (copy-sequence conn) (emacsql--ref conn))
               emacsql-connections)))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]