| 242 | self.port = kwargs.get("port", 8050) |
| 243 | |
| 244 | def target(): |
| 245 | app.scripts.config.serve_locally = True |
| 246 | app.css.config.serve_locally = True |
| 247 | |
| 248 | options = kwargs.copy() |
| 249 | |
| 250 | try: |
| 251 | module = app.server.__class__.__module__ |
| 252 | # FastAPI support |
| 253 | if module.startswith("fastapi"): |
| 254 | app.run(**options) |
| 255 | # Quart support (ASGI - runs its own async event loop) |
| 256 | elif module.startswith("quart"): |
| 257 | app.run(**options) |
| 258 | # Flask fallback (WSGI - needs threaded mode) |
| 259 | else: |
| 260 | app.run(threaded=True, **options) |
| 261 | except SystemExit: |
| 262 | logger.info("Server stopped") |
| 263 | raise |
| 264 | except Exception as error: |
| 265 | logger.exception(error) |
| 266 | raise error |
| 267 | |
| 268 | self.proc = multiprocess.Process(target=target) # type: ignore[reportAttributeAccessIssue]; pylint: disable=not-callable |
| 269 | self.proc.start() |