Skip to content

Commit

Permalink
Remove seek() for botostore and set seekable: False for it, because t…
Browse files Browse the repository at this point in the history
…he KeyFile implementation is buggy and leaks http connections.
  • Loading branch information
Cornelius Riemenschneider committed Jan 12, 2018
1 parent 25afce4 commit 17fdc66
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
@@ -1,5 +1,9 @@
Changelog
*********
0.11.7
======
* removed seek() and tell() API for file handles opened in the botostore, due to it leaking HTTP connections to S3.

0.11.6
======
* Support seek() and tell() API for file handles opened in the botostore.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@ def read(fname):


setup(name='simplekv',
version='0.11.6',
version='0.11.7',
description=('A key-value storage for binary data, support many '
'backends.'),
long_description=read('README.rst'),
Expand Down
18 changes: 1 addition & 17 deletions simplekv/net/botostore.py
Expand Up @@ -99,27 +99,11 @@ def read(self, size=-1):
return KeyFile.read(self, size)

def seekable(self):
return True
return False

def readable(self):
return True

def seek(self, offset, whence=os.SEEK_SET):
if self.closed:
raise ValueError("I/O operation on closed file")
if whence == os.SEEK_SET:
if offset < 0:
raise IOError('seek would move position outside the file')
return KeyFile.seek(self, offset, whence)
elif whence == os.SEEK_CUR:
if self.tell() + offset < 0:
raise IOError('seek would move position outside the file')
return KeyFile.seek(self, offset, whence)
elif whence == os.SEEK_END:
if self.key.size + offset < 0:
raise IOError('seek would move position outside the file')
return KeyFile.seek(self, offset, whence)

k = self.__new_key(key)
with map_boto_exceptions(key=key):
return SimpleKeyFile(k)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_boto_store.py
Expand Up @@ -9,7 +9,7 @@
from simplekv.net.botostore import BotoStore
from simplekv._compat import BytesIO

from basic_store import BasicStore, OpenSeekTellStore
from basic_store import BasicStore
from url_store import UrlStore
from bucket_manager import boto_credentials, boto_bucket
from conftest import ExtendedKeyspaceTests
Expand All @@ -28,7 +28,7 @@ def bucket(credentials):
yield bucket


class TestBotoStorage(BasicStore, UrlStore, OpenSeekTellStore):
class TestBotoStorage(BasicStore, UrlStore):
@pytest.fixture(params=[True, False])
def reduced_redundancy(self, request):
return request.param
Expand Down

0 comments on commit 17fdc66

Please sign in to comment.