diff options
author | Aarni Koskela <akx@iki.fi> | 2021-11-30 17:20:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-30 17:20:43 +0200 |
commit | fbe87acf96aab583975ed3371423eb20602eccaf (patch) | |
tree | b873c3356b9c96e826c4ab0bb3efc339a00838e4 /benchmarks/command_packer_benchmark.py | |
parent | 4db85ef574a64a2b230a3ae1ff19c9d04065a114 (diff) | |
download | redis-py-fbe87acf96aab583975ed3371423eb20602eccaf.tar.gz |
Pyupgrade + flynt + f-strings (#1759)
@akx Thank you so much for this! Thanks again for introducing me to a new tool that I'm sliding into my workflow as well.
Diffstat (limited to 'benchmarks/command_packer_benchmark.py')
-rw-r--r-- | benchmarks/command_packer_benchmark.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/benchmarks/command_packer_benchmark.py b/benchmarks/command_packer_benchmark.py index 823a8c8..3176c06 100644 --- a/benchmarks/command_packer_benchmark.py +++ b/benchmarks/command_packer_benchmark.py @@ -1,4 +1,3 @@ -import socket from redis.connection import (Connection, SYM_STAR, SYM_DOLLAR, SYM_EMPTY, SYM_CRLF) from base import Benchmark @@ -11,14 +10,13 @@ class StringJoiningConnection(Connection): self.connect() try: self._sock.sendall(command) - except socket.error as e: + except OSError as e: self.disconnect() if len(e.args) == 1: _errno, errmsg = 'UNKNOWN', e.args[0] else: _errno, errmsg = e.args - raise ConnectionError("Error %s while writing to socket. %s." % - (_errno, errmsg)) + raise ConnectionError(f"Error {_errno} while writing to socket. {errmsg}.") except Exception: self.disconnect() raise @@ -43,14 +41,13 @@ class ListJoiningConnection(Connection): command = [command] for item in command: self._sock.sendall(item) - except socket.error as e: + except OSError as e: self.disconnect() if len(e.args) == 1: _errno, errmsg = 'UNKNOWN', e.args[0] else: _errno, errmsg = e.args - raise ConnectionError("Error %s while writing to socket. %s." % - (_errno, errmsg)) + raise ConnectionError(f"Error {_errno} while writing to socket. {errmsg}.") except Exception: self.disconnect() raise |