Skip to content
New issue

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

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

Already on GitHub? # to your account

Avoid KeyError when filtering fetchable partitions #1344

Merged
merged 2 commits into from
Jan 12, 2018
Merged

Conversation

dpkp
Copy link
Owner

@dpkp dpkp commented Jan 12, 2018

I noticed this failure in a failed travis run. If we attempt to remove a partition that is not currently fetchable, the set will raise a KeyError. To avoid, we test that the element is in the set before removing it.

@tvoinarovskyi
Copy link
Collaborator

jfyi, discard can be used here, as it's a set.

>>> x = set([1, 2, 3])
>>> x.remove(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 0
>>> x.discard(0)
>>> x
{1, 2, 3}
>>> x.discard(1)
>>> x
{2, 3}

@dpkp
Copy link
Owner Author

dpkp commented Jan 12, 2018 via email

@dpkp dpkp merged commit 298709d into master Jan 12, 2018
@dpkp dpkp deleted the fetchable_key_error branch February 16, 2018 19:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants