Start Comfy API

UnboundLocalError: cannot access local variable 'socket' where it is not associated with a value // Werkzeug Debugger

UnboundLocalError

UnboundLocalError: cannot access local variable 'socket' where it is not associated with a value

Traceback (most recent call last)

  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 1536, in __call__

        ) -> cabc.Iterable[bytes]:
            """The WSGI server calls the Flask application object as the
            WSGI application. This calls :meth:`wsgi_app`, which can be
            wrapped to apply middleware.
            """
            return self.wsgi_app(environ, start_response)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask_socketio/__init__.py", line 42, in __call__

                             socketio_path=socketio_path)
     
        def __call__(self, environ, start_response):
            environ = environ.copy()
            environ['flask.app'] = self.flask_app
            return super().__call__(environ, start_response)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     
     
    class _ManagedSession(dict, SessionMixin):
        """This class is used for user sessions that are managed by
        Flask-SocketIO. It is simple dict, expanded with the Flask session
  • File "/opt/PyTorch/lib64/python3.11/site-packages/engineio/middleware.py", line 74, in __call__

                        '200 OK',
                        [('Content-Type', static_file['content_type'])])
                    with open(static_file['filename'], 'rb') as f:
                        return [f.read()]
                elif self.wsgi_app is not None:
                    return self.wsgi_app(environ, start_response)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            return self.not_found(start_response)
     
        def not_found(self, start_response):
            start_response("404 Not Found", [('Content-Type', 'text/plain')])
            return [b'Not Found']
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 1514, in wsgi_app

                try:
                    ctx.push()
                    response = self.full_dispatch_request()
                except Exception as e:
                    error = e
                    response = self.handle_exception(e)
                               ^^^^^^^^^^^^^^^^^^^^^^^^
                except:  # noqa: B001
                    error = sys.exc_info()[1]
                    raise
                return response(environ, start_response)
            finally:
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app

            ctx = self.request_context(environ)
            error: BaseException | None = None
            try:
                try:
                    ctx.push()
                    response = self.full_dispatch_request()
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                except Exception as e:
                    error = e
                    response = self.handle_exception(e)
                except:  # noqa: B001
                    error = sys.exc_info()[1]
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request

                request_started.send(self, _async_wrapper=self.ensure_sync)
                rv = self.preprocess_request()
                if rv is None:
                    rv = self.dispatch_request()
            except Exception as e:
                rv = self.handle_user_exception(e)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            return self.finalize_request(rv)
     
        def finalize_request(
            self,
            rv: ft.ResponseReturnValue | HTTPException,
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request

     
            try:
                request_started.send(self, _async_wrapper=self.ensure_sync)
                rv = self.preprocess_request()
                if rv is None:
                    rv = self.dispatch_request()
                         ^^^^^^^^^^^^^^^^^^^^^^^
            except Exception as e:
                rv = self.handle_user_exception(e)
            return self.finalize_request(rv)
     
        def finalize_request(
  • File "/opt/PyTorch/lib64/python3.11/site-packages/flask/app.py", line 902, in dispatch_request

                and req.method == "OPTIONS"
            ):
                return self.make_default_options_response()
            # otherwise dispatch to the handler for that endpoint
            view_args: dict[str, t.Any] = req.view_args  # type: ignore[assignment]
            return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     
        def full_dispatch_request(self) -> Response:
            """Dispatches the request and on top of that performs request
            pre and postprocessing as well as HTTP exception catching and
            error handling.
  • File "/srv/www/cgi-bin/Ai/stable-diffusion/ComfyUI/api.py", line 67, in load_workflow

          return None
      except json.JSONDecodeError:
          print(f"The file {path} contains invalid JSON.")
          return None
      finally:
        socket.close()
        ^^^^^^
     
    @app.route('/prompt', methods=['POST'])
    def prompt_to_image(workflow, positve_prompt, negative_prompt='', save_previews=False):
      client = str(uuid.uuid4().hex)
      token = request.headers['Authorization']
UnboundLocalError: cannot access local variable 'socket' where it is not associated with a value

This is the Copy/Paste friendly version of the traceback.

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.

Console Locked

The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.

PIN: