Skip to content

Commit 14e2294

Browse files
committed
Merge pull request #451 from basho/fixes/lrb/timeout-gh-425
READY: Recover from socket timeout
2 parents 5e0a909 + a883276 commit 14e2294

4 files changed

Lines changed: 29 additions & 2 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ riak.egg-info/
1414
.eggs/
1515
#*#
1616
*~
17-
*.ps1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Contributors
178178
* Mark Phillips
179179
* Mathias Meyer
180180
* Matt Heitzenroder
181+
* [Matt Lohier](https://github.com/aquam8)
181182
* Mikhail Sobolev
182183
* Reid Draper
183184
* Russell Brown

make.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
$env:RIAK_TEST_HOST = 'riak-test'
5+
$env:RIAK_TEST_PROTOCOL = 'pbc'
6+
$env:RIAK_TEST_PB_PORT = 10017
7+
$env:RUN_DATATYPES = 1
8+
$env:RUN_INDEXES = 1
9+
$env:RUN_POOL = 1
10+
$env:RUN_YZ = 1
11+
12+
flake8 --exclude=riak/pb riak commands.py setup.py version.py
13+
if ($LastExitCode -ne 0) {
14+
throw 'flake8 failed!'
15+
}
16+
17+
python setup.py test
18+
if ($LastExitCode -ne 0) {
19+
throw 'python tests failed!'
20+
}

riak/transports/tcp/connection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ def _ssl_handshake(self):
160160
raise SecurityError(e)
161161

162162
def _recv_msg(self):
163-
msgbuf = self._recv_pkt()
163+
try:
164+
msgbuf = self._recv_pkt()
165+
except socket.timeout as e:
166+
# A timeout can leave the socket in an inconsistent state because
167+
# it might still receive the data later and mix up with a
168+
# subsequent request.
169+
# https://github.com/basho/riak-python-client/issues/425
170+
raise BadResource(e)
164171
mv = memoryview(msgbuf)
165172
msg_code, = struct.unpack("B", mv[0:1])
166173
data = mv[1:].tobytes()

0 commit comments

Comments
 (0)