Skip to content

Commit

Permalink
ensure PJ state is refreshed regularly
Browse files Browse the repository at this point in the history
  • Loading branch information
3ll3d00d committed Dec 27, 2023
1 parent a8a4f9b commit 6d460bd
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 190 deletions.
13 changes: 13 additions & 0 deletions cmdserver/infoprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from requests import ConnectTimeout
from twisted.internet import task, threads
from twisted.internet.defer import Deferred
from urllib3.exceptions import MaxRetryError

from cmdserver.config import Config
from cmdserver.ws import WsServer
Expand Down Expand Up @@ -91,6 +92,18 @@ def __async_refresh(self):
except ConnectTimeout as e:
logger.warning(f"Unable to connect, MC probably sleeping {e.request.method} {e.request.url}")
self.__broadcast_down()
except OSError as e:
if e.errno == 113:
logger.warning(f"Unable to connect, MC probably sleeping {e.request.method} {e.request.url}")
else:
e = e.__context__
while e is not None and not isinstance(e, OSError):
e = e.__context__
if e is not None and e.errno == 113:
logger.warning(f"Unable to connect, MC probably sleeping {e.request.method} {e.request.url}")
else:
logger.exception(f"Unknown OSError when refreshing current state of {self.__ms.address()}")
self.__broadcast_down()
except ConnectionRefusedError as e:
logger.error(f"Unable to connect, MC appears down")
self.__broadcast_down()
Expand Down
2 changes: 1 addition & 1 deletion cmdserver/jvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

DEFAULT_PORT = 20554

logger = logging.getLogger(__name__)
logger = logging.getLogger('jvc')


class Error(Exception):
Expand Down
Loading

0 comments on commit 6d460bd

Please sign in to comment.