Преглед изворни кода

Ensure segment thread isn't killed prematurely on download end

Cammy пре 5 година
родитељ
комит
029c84e3f7
3 измењених фајлова са 9 додато и 3 уклоњено
  1. 1 0
      pyinstalive/dlfuncs.py
  2. 5 2
      pyinstalive/helpers.py
  3. 3 1
      pyinstalive/pil.py

+ 1 - 0
pyinstalive/dlfuncs.py

@@ -143,6 +143,7 @@ def merge_segments():
         live_segments_path = os.path.normpath(pil.broadcast_downloader.output_dir)
 
         if pil.segments_json_thread_worker and pil.segments_json_thread_worker.is_alive():
+            pil.kill_segment_thread = True
             pil.segments_json_thread_worker.join()
 
         if pil.comment_thread_worker and pil.comment_thread_worker.is_alive():

+ 5 - 2
pyinstalive/helpers.py

@@ -81,7 +81,7 @@ def check_if_guesting():
 
 
 def generate_json_segments():
-    while not pil.broadcast_downloader.is_aborted:
+    while True:
         pil.livestream_obj['delay'] = (int(pil.epochtime) - pil.livestream_obj['published_time'])
         if 'initial_buffered_duration' not in pil.livestream_obj and pil.broadcast_downloader.initial_buffered_duration:
             pil.livestream_obj['initial_buffered_duration'] = pil.broadcast_downloader.initial_buffered_duration
@@ -92,7 +92,10 @@ def generate_json_segments():
             if not pil.broadcast_downloader.stream_id:
                 pil.broadcast_downloader.stream_id = pil.livestream_obj['id']
             #check_if_guesting()
-            time.sleep(2.5)
+            if pil.kill_segment_thread:
+                break
+            else:
+                time.sleep(2.5)
         except Exception as e:
             logger.warn(str(e))
 

+ 3 - 1
pyinstalive/pil.py

@@ -47,6 +47,7 @@ def initialize():
     global verbose
     global skip_merge
     global config_login_overridden
+    global kill_segment_thread
     ig_api = None
     ig_user = ""
     ig_pass = ""
@@ -81,4 +82,5 @@ def initialize():
     proxy = None
     verbose = False
     skip_merge = False
-    config_login_overridden = False
+    config_login_overridden = False
+    kill_segment_thread = False