Bach Do
Bach Do

Reputation: 1

How to solve this error when running Python Flask on MacOS

This is the error I got when I run python flask app on macOS. How can I solve it?

Traceback (most recent call last):
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/connexion/decorators/validation.py", line 184, in wrapper
    response = function(request)
  File "/Users/truongnguyen/Library/Python/3.6/lib/python/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/truongnguyen/vRoute_Algo/server/server.py", line 159, in algo_handler
    result = json.loads(results[process_key])
  File "<string>", line 2, in __getitem__
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/managers.py", line 772, in _callmethod
    raise convert_to_error(kind, result)
KeyError: '5c04fa020bfc60873bc7d34b-5c04fa020bfc60873bc7d34b'

Upvotes: 0

Views: 208

Answers (1)

balderman
balderman

Reputation: 23815

The line:

result = json.loads(results[process_key])

is creating a dict from string and looks for the key process_key.

The key is not in the dict so the KeyError is raised.

Look at the code of server.py line 159 and see how to avoid the issue.

Upvotes: 1

Related Questions