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

_sync.py:94: TypeError with python2.7 #74

Closed
ssbarnea opened this issue May 30, 2019 · 1 comment
Closed

_sync.py:94: TypeError with python2.7 #74

ssbarnea opened this issue May 30, 2019 · 1 comment

Comments

@ssbarnea
Copy link

ssbarnea commented May 30, 2019

While backoff seems to be working on python 3.5-3.7, it seems that that it fails with python27 giving a weird exception, even for a simple use case:

@backoff.on_exception(backoff.expo,
                      requests.exceptions.RequestException,
                      max_time=60)
def test_delete_project(cl_admin, cl_normal, slug):

    with pytest.raises(JIRAError) as ex:
        assert cl_normal.delete_project(slug)

        assert 'Not enough permissions to delete project' in str(ex.value) \
            or str(ex.value).endswith('is not a Project, projectID or slug')

    assert cl_admin.delete_project(slug)

Failure:

__________________________________________________________________________________________________________________________ test_delete_project __________________________________________________________________________________________________________________________

args = (), kwargs = {}, max_tries_ = None, max_time_ = 60, tries = 1, start = datetime.datetime(2019, 5, 30, 8, 38, 0, 783162), wait = <generator object expo at 0x10cd4a5f0>, elapsed = 8e-06
details = (<function test_delete_project at 0x10cc6d1b8>, (), {}, 1, 8e-06)

    @functools.wraps(target)
    def retry(*args, **kwargs):

        # change names because python 2.x doesn't have nonlocal
        max_tries_ = _maybe_call(max_tries)
        max_time_ = _maybe_call(max_time)

        tries = 0
        start = datetime.datetime.now()
        wait = _init_wait_gen(wait_gen, wait_gen_kwargs)
        while True:
            tries += 1
            elapsed = timedelta.total_seconds(datetime.datetime.now() - start)
            details = (target, args, kwargs, tries, elapsed)

            try:
>               ret = target(*args, **kwargs)
E               TypeError: test_delete_project() takes exactly 3 arguments (0 given)

.tox/py27/lib/python2.7/site-packages/backoff/_sync.py:94: TypeError

Update: I ended up using tenacity.retry which aparantly works with all python versiosns.

@bgreen-litl
Copy link
Member

Sorry for the delay.

This appears like you were calling test_delete_project() without any arguments.

There are unit tests which cover these basic cases and they are run on travis across all platforms. Additionally I just ran some basic tests on python 2.7 and I'm not seeing any issues. It looks like you're decorating the function correctly, but you didn't include how you were calling it so I'm wondering if there is something unusual on that side.

Since I can't reproduce this I am closing but please reopen if there is something I'm missing.

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

No branches or pull requests

2 participants