Skip to content

Commit

Permalink
Periodically flush whilst moonlight pairing process is alive; as 'exp…
Browse files Browse the repository at this point in the history
…ect_unbuffer' is not included in Kodi by default.
  • Loading branch information
stickman89 committed Dec 21, 2020
1 parent 0853e74 commit bd2fed2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import threading
import os
import sys

import xbmc
from resources.lib.di.requiredfeature import RequiredFeature
Expand All @@ -16,14 +17,15 @@ def __init__(self, crypto_provider):

def pair(self, nvhttp, server_info, dialog):
self.logger.info('[MoonlightHelper] - Attempting to pair host: ' + self.config_helper.host_ip)
pairing_proc = subprocess.Popen(["expect_unbuffer", "moonlight", "pair"], cwd="/storage/moonlight", env={'LD_LIBRARY_PATH': '/storage/moonlight'}, shell=False, stdout=subprocess.PIPE, preexec_fn=os.setsid)
pairing_proc = subprocess.Popen(["moonlight", "pair"], cwd="/storage/moonlight", env={'LD_LIBRARY_PATH': '/storage/moonlight'}, shell=False, stdout=subprocess.PIPE, preexec_fn=os.setsid)
lines_iterator = iter(pairing_proc.stdout.readline, b"")

pairing_thread = threading.Thread(target=self.loop_lines, args=(self.logger, lines_iterator, dialog))
pairing_thread.start()

while True:
xbmc.sleep(1000)
sys.stdout.flush()
if not pairing_thread.isAlive():
break

Expand Down

0 comments on commit bd2fed2

Please sign in to comment.