From f11231ebb75510e3f9b9ec1fdc15d19481b546cb Mon Sep 17 00:00:00 2001 From: N1tR0 Date: Tue, 5 Jul 2022 16:37:59 +0200 Subject: [PATCH] Fix crash if discord is started after GW2RPC --- gw2rpc/gw2rpc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gw2rpc/gw2rpc.py b/gw2rpc/gw2rpc.py index fdb0c2e..a90141b 100644 --- a/gw2rpc/gw2rpc.py +++ b/gw2rpc/gw2rpc.py @@ -20,6 +20,7 @@ from .mumble import MumbleData from .settings import config from .sdk import DiscordSDK +from .lib.discordsdk import exception as sdk_exception import sys import os @@ -731,7 +732,15 @@ def check_for_running_rpc(): try: if self.sdk.app: self.sdk.set_activity(data) - self.sdk.app.run_callbacks() + try: + self.sdk.app.run_callbacks() + except sdk_exception.not_running: + # Probably a bug in the SDK library: + # Crashes if discord is started after RPC is already running + # Need to close the sdk connection and continue + # New sdk connection will be opened on next iteration + self.sdk.close() + continue except BrokenPipeError: raise GameNotRunningError # To start a new connection self.timeticks = (self.timeticks + 1) % 1000