mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Audio] Fix UnboundLocalError in edge case (#5394)
* Fix UnboundLocalError in edge case * Fix typehint for fetch * Style
This commit is contained in:
parent
05cd11b657
commit
b05933274a
@ -84,7 +84,9 @@ class PlaylistWrapper:
|
|||||||
table = 2
|
table = 2
|
||||||
return table
|
return table
|
||||||
|
|
||||||
async def fetch(self, scope: str, playlist_id: int, scope_id: int) -> PlaylistFetchResult:
|
async def fetch(
|
||||||
|
self, scope: str, playlist_id: int, scope_id: int
|
||||||
|
) -> Optional[PlaylistFetchResult]:
|
||||||
"""Fetch a single playlist."""
|
"""Fetch a single playlist."""
|
||||||
scope_type = self.get_scope_type(scope)
|
scope_type = self.get_scope_type(scope)
|
||||||
|
|
||||||
@ -107,7 +109,8 @@ class PlaylistWrapper:
|
|||||||
try:
|
try:
|
||||||
row_result = future.result()
|
row_result = future.result()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_exc_log(log, exc, "Failed to completed playlist fetch from database")
|
debug_exc_log(log, exc, "Failed to complete playlist fetch from database")
|
||||||
|
return None
|
||||||
row = row_result.fetchone()
|
row = row_result.fetchone()
|
||||||
if row:
|
if row:
|
||||||
row = PlaylistFetchResult(*row)
|
row = PlaylistFetchResult(*row)
|
||||||
@ -139,7 +142,7 @@ class PlaylistWrapper:
|
|||||||
try:
|
try:
|
||||||
row_result = future.result()
|
row_result = future.result()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_exc_log(log, exc, "Failed to completed playlist fetch from database")
|
debug_exc_log(log, exc, "Failed to complete playlist fetch from database")
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
for future in concurrent.futures.as_completed(
|
for future in concurrent.futures.as_completed(
|
||||||
@ -154,7 +157,7 @@ class PlaylistWrapper:
|
|||||||
try:
|
try:
|
||||||
row_result = future.result()
|
row_result = future.result()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_exc_log(log, exc, "Failed to completed playlist fetch from database")
|
debug_exc_log(log, exc, "Failed to complete playlist fetch from database")
|
||||||
return []
|
return []
|
||||||
async for row in AsyncIter(row_result):
|
async for row in AsyncIter(row_result):
|
||||||
output.append(PlaylistFetchResult(*row))
|
output.append(PlaylistFetchResult(*row))
|
||||||
@ -191,7 +194,8 @@ class PlaylistWrapper:
|
|||||||
try:
|
try:
|
||||||
row_result = future.result()
|
row_result = future.result()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_exc_log(log, exc, "Failed to completed fetch from database")
|
debug_exc_log(log, exc, "Failed to complete fetch from database")
|
||||||
|
return []
|
||||||
|
|
||||||
async for row in AsyncIter(row_result):
|
async for row in AsyncIter(row_result):
|
||||||
output.append(PlaylistFetchResult(*row))
|
output.append(PlaylistFetchResult(*row))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user