Skip to content

Commit 3af398f

Browse files
committed
Catch socket errors when testing for Database/Server existence
1 parent 8561f55 commit 3af398f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

couchdb/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from textwrap import dedent
3232
import warnings
3333
import sys
34+
import socket
3435

3536
from couchdb import http, json, util
3637

@@ -95,7 +96,7 @@ def __contains__(self, name):
9596
try:
9697
self.resource.head(name)
9798
return True
98-
except http.ResourceNotFound:
99+
except (socket.error, http.ResourceNotFound):
99100
return False
100101

101102
def __iter__(self):
@@ -113,7 +114,7 @@ def __nonzero__(self):
113114
try:
114115
self.resource.head()
115116
return True
116-
except http.ResourceNotFound:
117+
except (socket.error, http.ResourceNotFound):
117118
return False
118119

119120
def __bool__(self):

0 commit comments

Comments
 (0)