fixed memory leak related to video files

This commit is contained in:
2026-03-29 13:31:27 +02:00
parent 5662f079eb
commit 4cdccb7227
8 changed files with 36 additions and 22 deletions

View File

@@ -83,8 +83,8 @@ class Commands(commands.Cog):
await discordHelper.ensure_has_channel_or_thread(artist, interaction.guild, botData.db)
image_containers : list[x_posts_images] = []
media = await tweetHelper.GetTweetMediaUrls(tweet)
image_containers = [x_posts_images(tweet.id, idx, file = url) for idx, url in enumerate(media)]
media = await tweetHelper.GetTweetMedia(tweet)
image_containers = [x_posts_images(tweet.id, idx, file = med.url) for idx, med in enumerate(media)]
async with aiohttp.ClientSession() as session:
downloaded_media = await tweetHelper.DownloadMedia(tweet.id, tweet.author.id, tweet.author.username, media, session)
@@ -94,7 +94,7 @@ class Commands(commands.Cog):
for idx, attachment in enumerate(downloaded_media):
container = image_containers[idx]
container.saved_file = attachment.file_name
container.vox_label, container.rating, container.tags, filtered_tags, container.phash, container.dhash, container.error_id = await classify_all(attachment.file_bytes, botData.classifier, botData.vox)
container.vox_label, container.rating, container.tags, filtered_tags, container.phash, container.dhash, container.error_id = await classify_all(attachment.file_bytes if not attachment.is_video else None, botData.classifier, botData.vox)
if container.vox_label not in vox_labels:
vox_labels.append(container.vox_label)