Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

can not pass arguments to @eventually_consistent.call #25

Closed
tmatsuo opened this issue Apr 3, 2020 · 1 comment · Fixed by #26
Closed

can not pass arguments to @eventually_consistent.call #25

tmatsuo opened this issue Apr 3, 2020 · 1 comment · Fixed by #26
Assignees

Comments

@tmatsuo
Copy link
Contributor

tmatsuo commented Apr 3, 2020

When I do something like:

@eventually_consistent.call(tries=5)
def_():
    #do something

I got:

TypeError: call() missing 1 required positional argument: 'f'
@tmatsuo
Copy link
Contributor Author

tmatsuo commented Apr 3, 2020

IIRC, for implementing decorators with arguments, you need to do something like:

def call(*args, **kwargs): 
    def inner(func): 
        #...
    return inner

tmatsuo pushed a commit to tmatsuo/python-docs-samples that referenced this issue Apr 3, 2020
fixes GoogleCloudPlatform#2945
fixes GoogleCloudPlatform#2818

There were 8 tests which has `time.sleep(10)` for waiting data
propagation or whatever. I chose to use `@eventually_consistent.call`
instead of sleep in those tests.

Bonus point is now the tests are significantly faster because it doesn't
always wait for 10 seconds.

The downside is it will take a long time on failure. We may want to
specify the retry count on the eventualy consistent decorator once the
following issue is fixed:

GoogleCloudPlatform/python-repo-tools#25
tmatsuo pushed a commit to tmatsuo/python-docs-samples that referenced this issue Apr 3, 2020
fixes GoogleCloudPlatform#2945
fixes GoogleCloudPlatform#2818

There were 8 tests which has `time.sleep(10)` for waiting data
propagation or whatever. I chose to use `@eventually_consistent.call`
instead of sleep in those tests.

Bonus point is now the tests are significantly faster because it doesn't
always wait for 10 seconds.

The downside is it will take a long time on failure. We may want to
specify the retry count on the eventualy consistent decorator once the
following issue is fixed:

GoogleCloudPlatform/python-repo-tools#25
tmatsuo pushed a commit to tmatsuo/python-docs-samples that referenced this issue Apr 3, 2020
fixes GoogleCloudPlatform#2945
fixes GoogleCloudPlatform#2818

There were 8 tests which has `time.sleep(10)` for waiting data
propagation or whatever. I chose to use `@eventually_consistent.call`
instead of sleep in those tests.

Bonus point is now the tests are significantly faster because it doesn't
always wait for 10 seconds.

The downside is it will take a long time on failure. We may want to
specify the retry count on the eventualy consistent decorator once the
following issue is fixed:

GoogleCloudPlatform/python-repo-tools#25
@tmatsuo tmatsuo self-assigned this Apr 4, 2020
tmatsuo pushed a commit to tmatsuo/python-repo-tools that referenced this issue Apr 4, 2020
* correctly handle argument provided to the decorators
* provide the real callback for retry_on_exception instead of None

fixes GoogleCloudPlatform#25

The helper function `_retry_on_exception` didn't return the inner
function properly so that, it is always None.

Luckily, if you pass `None` to `retry_on_exception` argument, the
retrying module always retries as shown bellow:

https://github.com/rholder/retrying/blob/1d5699348d707e377aad7488da6a8a1b48a65933/retrying.py#L139

Previously, you can not pass any arguments to the decorator `mark` and `call`.
This PR will allow both syntax with or without arguments.

I also added unit tests to this module. I'm not sure if we have CI
builds, but the test passes locally.
tmatsuo pushed a commit to GoogleCloudPlatform/python-docs-samples that referenced this issue Apr 7, 2020
* [jobs] testing: reduce test flakiness

fixes #2945
fixes #2818

There were 8 tests which has `time.sleep(10)` for waiting data
propagation or whatever. I chose to use `@eventually_consistent.call`
instead of sleep in those tests.

Bonus point is now the tests are significantly faster because it doesn't
always wait for 10 seconds.

The downside is it will take a long time on failure. We may want to
specify the retry count on the eventualy consistent decorator once the
following issue is fixed:

GoogleCloudPlatform/python-repo-tools#25

* style fix
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant