From 3f17c90a8b92a79c41dd1b17f88a6efed2f2e396 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sat, 24 May 2025 17:31:52 -0500 Subject: [PATCH] Cleaned up some old unneeded code. --- apps/epg/tasks.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/apps/epg/tasks.py b/apps/epg/tasks.py index 088016f3..80bd18df 100644 --- a/apps/epg/tasks.py +++ b/apps/epg/tasks.py @@ -588,27 +588,13 @@ def parse_channels_only(source): logger.info(f"[parse_channels_only] Memory before opening file: {process.memory_info().rss / 1024 / 1024:.2f} MB") try: - # Create a parser with the desired options - #parser = etree.XMLParser(huge_tree=True, remove_blank_text=True) - - # Count channels for progress reporting - use proper lxml approach - # Open the file first - logger.info(f"Opening file for initial channel count: {file_path}") - source_file = gzip.open(file_path, 'rb') if is_gzipped else open(file_path, 'rb') - if process: - logger.info(f"[parse_channels_only] Memory after opening file: {process.memory_info().rss / 1024 / 1024:.2f} MB") - - # Count channels + # Attempt to count existing channels in the database try: total_channels = EPGData.objects.filter(epg_source=source).count() logger.info(f"Found {total_channels} existing channels for this source") except Exception as e: logger.error(f"Error counting channels: {e}") total_channels = 500 # Default estimate - - # Close the file to reset position - logger.debug(f"Closing initial file handle") - source_file.close() if process: logger.debug(f"[parse_channels_only] Memory after closing initial file: {process.memory_info().rss / 1024 / 1024:.2f} MB") @@ -616,10 +602,10 @@ def parse_channels_only(source): send_epg_update(source.id, "parsing_channels", 25, total_channels=total_channels) # Reset file position for actual processing - logger.debug(f"Re-opening file for channel parsing: {file_path}") + logger.debug(f"Opening file for channel parsing: {file_path}") source_file = gzip.open(file_path, 'rb') if is_gzipped else open(file_path, 'rb') if process: - logger.debug(f"[parse_channels_only] Memory after re-opening file: {process.memory_info().rss / 1024 / 1024:.2f} MB") + logger.debug(f"[parse_channels_only] Memory after opening file: {process.memory_info().rss / 1024 / 1024:.2f} MB") # Change iterparse to look for both channel and programme elements logger.debug(f"Creating iterparse context for channels and programmes")