Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyRacer1337 authored and 4c0d3r committed May 17, 2022
1 parent 37833b8 commit 1c1b519
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions namer/web/server.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
A wrapper allowing shutdown of a Flask server.
"""
from typing import Any
from typing import Union

from flask import Flask
from flask_compress import Compress
from waitress import create_server
from waitress.server import BaseWSGIServer, MultiSocketServer

from namer.types import NamerConfig
from namer.web.routes import get_web_routes
Expand All @@ -18,7 +19,7 @@ class WebServer:
"""
A wrapper allowing shutdown of a Flask server.
"""
__server: Any # MultiSocketServer | BaseWSGIServer
__server: Union[MultiSocketServer, BaseWSGIServer]
__config: NamerConfig
__debug: bool

Expand Down Expand Up @@ -49,4 +50,5 @@ def stop(self):
"""
Stop severing requests and empty threads.
"""
self.__server.close()
if self.__server:
self.__server.close()

0 comments on commit 1c1b519

Please sign in to comment.