Merge pull request #7902 from Ultimaker/CURA-7490_authorization_server_cpu_usage

Fix Authorization server not properly stopping after flow completes.
This commit is contained in:
Jaime van Kessel 2020-06-09 17:27:25 +02:00 committed by GitHub
commit 1747dea203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -2,6 +2,7 @@
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from http.server import HTTPServer from http.server import HTTPServer
from socketserver import ThreadingMixIn
from typing import Callable, Any, TYPE_CHECKING from typing import Callable, Any, TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
@ -9,7 +10,7 @@ if TYPE_CHECKING:
from cura.OAuth2.AuthorizationHelpers import AuthorizationHelpers from cura.OAuth2.AuthorizationHelpers import AuthorizationHelpers
class AuthorizationRequestServer(HTTPServer): class AuthorizationRequestServer(ThreadingMixIn, HTTPServer):
"""The authorization request callback handler server. """The authorization request callback handler server.
This subclass is needed to be able to pass some data to the request handler. This cannot be done on the request This subclass is needed to be able to pass some data to the request handler. This cannot be done on the request

View File

@ -81,6 +81,7 @@ class LocalAuthorizationServer:
if self._web_server: if self._web_server:
try: try:
self._web_server.shutdown()
self._web_server.server_close() self._web_server.server_close()
except OSError: except OSError:
# OS error can happen if the socket was already closed. We really don't care about that case. # OS error can happen if the socket was already closed. We really don't care about that case.