[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql bb3dbfc891 213/427: Set a global query timeout.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql bb3dbfc891 213/427: Set a global query timeout. |
Date: |
Tue, 13 Dec 2022 02:59:43 -0500 (EST) |
branch: elpa/emacsql
commit bb3dbfc8914f8d9caad47a0a6b1fb978114f7ae0
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Set a global query timeout.
---
emacsql-compiler.el | 1 +
emacsql.el | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index 982e435922..9a7f8b57e6 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -22,6 +22,7 @@
(emacsql-deferror emacsql-transaction () "Invalid transaction")
(emacsql-deferror emacsql-fatal () "Fatal error")
(emacsql-deferror emacsql-access () "Database access error")
+(emacsql-deferror emacsql-timeout () "Query timeout error")
(defun emacsql-error (format &rest args)
"Like `error', but signal an emacsql-syntax condition."
diff --git a/emacsql.el b/emacsql.el
index f3f426840f..44f9187d65 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -63,6 +63,10 @@
(require 'finalize)
(require 'emacsql-compiler)
+(defvar emacsql-global-timeout 30
+ "Maximum number of seconds to wait before bailing out on a SQL command.
+If nil, wait forever.")
+
(defclass emacsql-connection ()
((process :type process
:initarg :process
@@ -121,10 +125,13 @@ MESSAGE should not have a newline on the end."
(defmethod emacsql-wait ((connection emacsql-connection) &optional timeout)
"Block until CONNECTION is waiting for further input."
- (let ((end (when timeout (+ (float-time) timeout))))
- (while (and (or (null timeout) (< (float-time) end))
+ (let* ((real-timeout (or timeout emacsql-global-timeout))
+ (end (when real-timeout (+ (float-time) real-timeout))))
+ (while (and (or (null real-timeout) (< (float-time) end))
(not (emacsql-waiting-p connection)))
- (accept-process-output (emacsql-process connection) timeout))))
+ (accept-process-output (emacsql-process connection) real-timeout))
+ (unless (emacsql-waiting-p connection)
+ (signal 'emacsql-timeout (list "Query timed out" real-timeout)))))
(defgeneric emacsql-parse (connection)
"Return the results of parsing the latest output or signal an error.")
- [nongnu] elpa/emacsql a13eba5f05 059/427: Use the timeout argument in emacsql-wait., (continued)
- [nongnu] elpa/emacsql a13eba5f05 059/427: Use the timeout argument in emacsql-wait., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d440b44778 076/427: Add escape vector test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1db49d7f4c 090/427: Add Windows notice again., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1ad58cd68d 108/427: Allow substatement in IN operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8fa7c00978 170/427: Add sentinel cleanup to psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6d17256e1b 171/427: Add a mix-in class to reduce code duplication., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 749becb017 181/427: Disable notices and warnings in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e42d939235 187/427: In SQLite, block for up to 30 seconds on db lock., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3ba9109d45 198/427: Start using real version numbers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql de0bde9a02 207/427: Use Cask package-file directive instead., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb3dbfc891 213/427: Set a global query timeout.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 394bb062aa 219/427: Add a small library for determining binary to use., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dc2afbbc1f 221/427: Adjust the Emacsql wire protocol., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6318472b20 223/427: Link the Makefiles together., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a7728339ba 216/427: Switch to custom middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1146f2e26a 233/427: Flesh out the changes in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed77eac846 237/427: Add string prepared statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847196cafa 226/427: Set tty to raw in psql., ELPA Syncer, 2022/12/13