Skip to content

Commit

Permalink
Ensure segment thread isn't killed prematurely on download end
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammy committed Aug 20, 2019
1 parent a75df02 commit 029c84e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyinstalive/dlfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 5 additions & 2 deletions pyinstalive/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
4 changes: 3 additions & 1 deletion pyinstalive/pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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

0 comments on commit 029c84e

Please sign in to comment.