[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e43b040 5/6: Excorporate: Add timeout for synchronous oper
From: |
Thomas Fitzsimmons |
Subject: |
[elpa] master e43b040 5/6: Excorporate: Add timeout for synchronous operations |
Date: |
Fri, 25 Sep 2020 22:32:45 -0400 (EDT) |
branch: master
commit e43b0407de0e60be91ebb6bf091583919cb485a9
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Excorporate: Add timeout for synchronous operations
* excorporate.el (exco--server-timeout): New variable.
(exco-operate-synchronously): Use exco--server-timeout.
(exco-organizer-smtp-email-address): Likewise. Document
synchronous operation.
---
packages/excorporate/excorporate.el | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/packages/excorporate/excorporate.el
b/packages/excorporate/excorporate.el
index 84c404c..b068121 100644
--- a/packages/excorporate/excorporate.el
+++ b/packages/excorporate/excorporate.el
@@ -137,6 +137,9 @@ state machine represents a service connection.")
(defvar exco--connection-identifiers nil
"An ordered list of connection identifiers.")
+(defvar exco--server-timeout 5
+ "The timeout in seconds to wait for a synchronous server response.")
+
(defun exco--parse-xml-in-current-buffer ()
"Decode and parse the XML contents of the current buffer."
(let ((mime-part (mm-dissect-buffer t t)))
@@ -648,7 +651,8 @@ IDENTIFIER is the connection identifier. Execute operation
NAME
with ARGUMENTS then call CALLBACK with two arguments, IDENTIFIER
and the server's response."
(exco--with-fsm identifier
- (fsm-call fsm (list name arguments))))
+ (with-timeout (exco--server-timeout (error "Timed out waiting for server"))
+ (fsm-call fsm (list name arguments)))))
(defun exco-server-version (identifier)
"Return the server version for connection IDENTIFIER, as a string.
@@ -867,7 +871,11 @@ argument ICALENDAR-TEXT."
"Return the organizer's SMTP email address as a string.
IDENTIFIER is the connection identifier to use to resolve
ORGANIZER-STRUCTURE to the returned value. ORGANIZER-STRUCTURE
-should be treated as opaque."
+should be treated as opaque.
+
+This function queries the server synchronously. It times out and
+returns nil if the server does not respond in under
+`exco--server-timeout' seconds."
(let* ((wrapped (list (list organizer-structure)))
(routing-type
(exco-extract-value '(Organizer Mailbox RoutingType) wrapped))
@@ -883,10 +891,11 @@ should be treated as opaque."
Mailbox
EmailAddress)
(with-timeout
- (2 (progn
- (message (concat "exco-organizer-smtp-email-address:"
- " Server did not respond in time"))
- nil))
+ (exco--server-timeout
+ (progn
+ (message (concat "exco-organizer-smtp-email-address:"
+ " Server did not respond in time"))
+ nil))
(exco-operate-synchronously identifier
"ResolveNames"
`(((UnresolvedEntry . ,email-address))
- [elpa] master updated (78c650b -> 535349a), Thomas Fitzsimmons, 2020/09/25
- [elpa] master 96b57cf 2/6: Excorporate: Expand responses in API usage examples, Thomas Fitzsimmons, 2020/09/25
- [elpa] master 436b625 3/6: Excorporate: Do not explicitly require Org package, Thomas Fitzsimmons, 2020/09/25
- [elpa] master 2fe5e56 1/6: Excorporate: Rewrite exco-org functions for Org 9.1, Thomas Fitzsimmons, 2020/09/25
- [elpa] master 4adac33 4/6: Excorporate: Add more API usage examples to manual, Thomas Fitzsimmons, 2020/09/25
- [elpa] master e43b040 5/6: Excorporate: Add timeout for synchronous operations,
Thomas Fitzsimmons <=
- [elpa] master 535349a 6/6: Excorporate: Rename a function, Thomas Fitzsimmons, 2020/09/25