Skip to content

Commit

Permalink
Fix crash if discord is started after GW2RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
N1tR0 committed Jul 5, 2022
1 parent b417907 commit f11231e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gw2rpc/gw2rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f11231e

Please sign in to comment.