Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gabor-boros committed Jul 17, 2018
1 parent 01bd807 commit 89db318
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
11 changes: 5 additions & 6 deletions rethinkdb/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ def run(self, c=None, **global_optargs):
c = Repl.get()
if c is None:
if Repl.replActive:
raise ReqlDriverError("RqlQuery.run must be given" +
" a connection to run on. A default connection" +
" has been set with `repl()` on another thread," +
" but not this one.")
raise ReqlDriverError(
"RqlQuery.run must be given a connection to run on. A default connection has been set with "
"`repl()` on another thread, but not this one."
)
else:
raise ReqlDriverError("RqlQuery.run must be given" +
" a connection to run on.")
raise ReqlDriverError("RqlQuery.run must be given a connection to run on.")

return c._start(self, **global_optargs)

Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/gevent_net/net_gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def close(self, noreply_wait=False, token=None, exception=None):

try:
self._socket.close()
except Exception:
except OSError:
pass

# TODO: make connection recoverable if interrupted by a user's gevent.Timeout?
Expand Down
6 changes: 3 additions & 3 deletions rethinkdb/handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def next_message(self, response):
)
json = self._json_decoder.decode(response)
try:
if not json["success"]:
if json["success"] is False:
if 10 <= json["error_code"] <= 20:
raise ReqlAuthError(json["error"], self._host, self._port)
else:
Expand All @@ -172,7 +172,7 @@ def next_message(self, response):
json = self._json_decoder.decode(response.decode("utf-8"))
server_first_message = r = salt = i = None
try:
if not json["success"]:
if json["success"] is False:
if 10 <= json["error_code"] <= 20:
raise ReqlAuthError(json["error"], self._host, self._port)
else:
Expand Down Expand Up @@ -241,7 +241,7 @@ def next_message(self, response):
json = self._json_decoder.decode(response.decode("utf-8"))
v = None
try:
if not json["success"]:
if json["success"] is False:
if 10 <= json["error_code"] <= 20:
raise ReqlAuthError(json["error"], self._host, self._port)
else:
Expand Down
7 changes: 2 additions & 5 deletions rethinkdb/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,23 +408,20 @@ def recvall(self, length, deadline):
raise ReqlTimeoutError(self.host, self.port)
except IOError as ex:
if ex.errno == errno.ECONNRESET:
self.close()
raise ReqlDriverError("Connection is closed.")
elif ex.errno == errno.EWOULDBLOCK:
# This should only happen with a timeout of 0
raise ReqlTimeoutError(self.host, self.port)
elif ex.errno != errno.EINTR:
self.close()
raise ReqlDriverError(('Connection interrupted ' +
'receiving from %s:%s - %s') %
(self.host, self.port, str(ex)))
except Exception as ex:
self.close()
raise ReqlDriverError('Error receiving from %s:%s - %s' %
(self.host, self.port, str(ex)))
except BaseException:
finally:
self.close()
raise

if len(chunk) == 0:
self.close()
raise ReqlDriverError("Connection is closed.")
Expand Down

0 comments on commit 89db318

Please sign in to comment.