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

Catch StopIteration raised by generator #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mamciek
Copy link

@mamciek mamciek commented Jan 15, 2020

When running on python 3.7+ then generator raises StopIteration exception

  Traceback (most recent call last):
    File "[..]/lib/python3.7/site-packages/snakebite/client.py", line 1549, in wrapped
      yield next(results)
  StopIteration

This expected according to https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior

PEP 479 is enabled for all code in Python 3.7, meaning that StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. 

@elukey
Copy link
Contributor

elukey commented Jan 26, 2020

Hi @mamciek ! I can't test the client on Python 3.7 now, but I should be able to do it soon. In the meantime, can you please add the full stacktrace that you get? I am not familiar with the code of client.py so I'd like to make sure to understand what _ha_gen_method does exactly.

@nlevitt you have more experience so if the patch looks trivial/ok-to-merge it might be a good candidate for a new minor version of snakebite?

@gloutsch
Copy link

gloutsch commented Jul 9, 2020

can you make a minor version to support python >= 3.7 please ? 😄

snakebite-py3==3.0.5

here is the stacktrace :

>>> [d['path'] for d in client.ls(['/'])]
Traceback (most recent call last):
  File "/opt/test/lib/python3.8/site-packages/snakebite/client.py", line 1549, in wrapped
    yield next(results)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <listcomp>
RuntimeError: generator raised StopIteration

@elukey
Copy link
Contributor

elukey commented Jul 15, 2020

@nlevitt hi! This is probably a good use case for a quick release if you have time during the next days :)

@pieterbork
Copy link

Any chance that this will get merged and released in the near future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants