Skip to content

Commit

Permalink
Allow some GQL operations to silently fail
Browse files Browse the repository at this point in the history
  • Loading branch information
DevilXD committed Aug 4, 2024
1 parent 4dcabee commit b20f98d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ async def _run(self):
# use the other set to set them online if possible
if acl_channels:
await asyncio.gather(
*(channel.update_stream(trigger_events=False) for channel in acl_channels)
*(channel.update_stream(trigger_events=False) for channel in acl_channels),
return_exceptions=True,
)
# finally, add them as new channels
new_channels.update(acl_channels)
Expand Down Expand Up @@ -868,12 +869,17 @@ async def _watch_loop(self) -> NoReturn:
handled: bool = False

# Solution 1: use GQL to query for the currently mined drop status
context = await self.gql_request(
GQL_OPERATIONS["CurrentDrop"].with_variables({"channelID": str(channel.id)})
)
drop_data: JsonType | None = (
context["data"]["currentUser"]["dropCurrentSession"]
)
try:
context = await self.gql_request(
GQL_OPERATIONS["CurrentDrop"].with_variables(
{"channelID": str(channel.id)}
)
)
drop_data: JsonType | None = (
context["data"]["currentUser"]["dropCurrentSession"]
)
except GQLException:
drop_data = None
if drop_data is not None:
drop = self._drops.get(drop_data["dropID"])
if drop is not None and drop.can_earn(channel):
Expand Down

0 comments on commit b20f98d

Please sign in to comment.