- commit
- b631036740165f8dc8c3a9eb5ead785dfb93abf5
- parent
- d5c44d829916b78c3e267869f9ade18652b75952
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-09-17 06:22
add timeout to http requests avoids infinite block on trying to write without network
Diffstat
| M | python/pad/__init__.py | 5 | +++-- |
1 files changed, 3 insertions, 2 deletions
diff --git a/python/pad/__init__.py b/python/pad/__init__.py
@@ -9,6 +9,7 @@ import vim 9 9 from . import diff 10 10 11 11 BASE_URL = 'https://via.ce9e.org/hmsg/pad/' -1 12 TIMEOUT = 4 12 13 13 14 session = requests.Session() 14 15 pads = {} @@ -73,7 +74,7 @@ class Pad: 73 74 self.local_changes = [] 74 75 data = [self.id, 'changes', self.staged_changes] 75 76 try:76 -1 r = session.post(self.url, json=data)-1 77 r = session.post(self.url, json=data, timeout=TIMEOUT) 77 78 r.raise_for_status() 78 79 except Exception as e: 79 80 print(e) @@ -123,7 +124,7 @@ class Pad: 123 124 data = [self.id, 'changes', [change]] 124 125 session.put(self.url, json=data, headers={ 125 126 'Last-Event-ID': self.last_event_id126 -1 })-1 127 }, timeout=TIMEOUT) 127 128 128 129 129 130 def get_buffer():