Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure _list_bucket uses continuation token for subsequent pages #246

Merged
merged 3 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion smart_open/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ def _list_bucket(bucket_name, prefix='', accept_key=lambda k: True):
ctoken = None

while True:
response = client.list_objects_v2(Bucket=bucket_name, Prefix=prefix)
# list_objects_v2 doesn't like a None value for ContinuationToken
# so we don't set it if we don't have one.
if ctoken:
response = client.list_objects_v2(Bucket=bucket_name, Prefix=prefix, ContinuationToken=ctoken)
else:
response = client.list_objects_v2(Bucket=bucket_name, Prefix=prefix)
try:
content = response['Contents']
except KeyError:
Expand Down
1 change: 0 additions & 1 deletion smart_open/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ def test_list_bucket(self):
expected = ['key_%d' % x for x in range(num_keys)]
self.assertEqual(sorted(keys), sorted(expected))

@unittest.skip('this test takes too long for some unknown reason')
Copy link
Owner

@piskvorky piskvorky Nov 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL! Did we catch the error, but commented out its test instead of fixing? :) Who did this?

def test_list_bucket_long(self):
num_keys = 1010
populate_bucket(num_keys=num_keys)
Expand Down