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

UrlFetchRpcHandler error #448

Closed
smorodsky opened this issue Aug 12, 2016 · 9 comments
Closed

UrlFetchRpcHandler error #448

smorodsky opened this issue Aug 12, 2016 · 9 comments
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@smorodsky
Copy link

smorodsky commented Aug 12, 2016

I used in the project slightly modifying class UrlFetchRpcHandler (file /appengine/standard/urlfetch/async/rpc.py)
Approximately once every 100,000 requests to receive an unexpected error:

UnboundLocalError: local variable 'result' referenced before assignment

It looks like the problem of garbage collection. Completely solve the problem by adding at the beginning define of the line

global result

I hope it will be useful.

@theacodes
Copy link
Contributor

Interesting. Do you happen to have a full stacktrace that you're willing to share with us?

@smorodsky
Copy link
Author

smorodsky commented Aug 15, 2016

Sorry for the delay, please:

local variable 'result' referenced before assignment
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/e~my-app/30.394225512022207104/my-app.py", line 250, in get
    self.do_req(url, headers)
  File "/base/data/home/apps/e~my-app/30.394225512022207104/my-app.py", line 300, in do_req
    if result.status_code == 200:
UnboundLocalError: local variable 'result' referenced before assignment

@theacodes
Copy link
Contributor

Do you mind sharing the do_req function's source with me?

@smorodsky
Copy link
Author

smorodsky commented Aug 16, 2016


def do_req(self, url, headers):
    global result
    rpc = urlfetch.create_rpc(deadline = 9)
    urlfetch.make_fetch_call(rpc, url, headers = headers)
    try:
      result = rpc.get_result()
    except Exception as e:
      logging.error(type(e).__name__ + ': ' + str(e))
      return
    if result.status_code == 200: # <-- UnboundLocalError here
      return result.content
...

@theacodes
Copy link
Contributor

@smorodsky I wrote more tests in #457 but I still can't reproduce this.

@smorodsky
Copy link
Author

smorodsky commented Aug 17, 2016

I made 200,000 calls google.com and did not get a single shot. The server to which real requests are responsible slower. Obviously, this increases the likelihood of failure. Errors may be missing a few hours and then go to series.

If it would be helpful, I can add you to a real project. It consistently repeat this error.

@theacodes
Copy link
Contributor

Sure - that might be helpful. It's strange though because the test cases I added should cover all failure paths.

@smorodsky
Copy link
Author

Excuse me, I'm an idiot.

In the original code, there is another block except, and it skipped return. I have many times check it this function, but i can not understand for what reason did not notice the bug. I'm really sorry, that gave rise to worry. Thank you.

@theacodes
Copy link
Contributor

@smorodsky don't sweat it! At least I got some shiny new tests out of it. :)

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
telpirion pushed a commit that referenced this issue Nov 16, 2022
* docs(nodejs_mono_repo): update broken links in README

Source-Link: googleapis/synthtool@50db768
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978

* trigger ci

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
dandhlee pushed a commit that referenced this issue Nov 18, 2022
* docs(nodejs_mono_repo): update broken links in README

Source-Link: googleapis/synthtool@50db768
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978

* trigger ci

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
dizcology pushed a commit that referenced this issue Jun 16, 2023
* fix: replaces deprecated snippet

* adds a test

* revises test assert statement

* fix linting

* examining return values

* examining more return values

* examining return values more betterly

* evaluating timestamps in use

* evaluating timestamps in use 2

* clean up test

* clean up linting
dizcology pushed a commit that referenced this issue Jul 10, 2023
* fix: replaces deprecated snippet

* adds a test

* revises test assert statement

* fix linting

* examining return values

* examining more return values

* examining return values more betterly

* evaluating timestamps in use

* evaluating timestamps in use 2

* clean up test

* clean up linting
leahecole pushed a commit that referenced this issue Jul 11, 2023
* fix: replaces deprecated snippet

* adds a test

* revises test assert statement

* fix linting

* examining return values

* examining more return values

* examining return values more betterly

* evaluating timestamps in use

* evaluating timestamps in use 2

* clean up test

* clean up linting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants