kill process the hard way in controllers.py
This commit is contained in:
		@ -2,6 +2,7 @@ import os
 | 
			
		||||
import re
 | 
			
		||||
import subprocess
 | 
			
		||||
import atexit
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from django.template.loader import render_to_string
 | 
			
		||||
 | 
			
		||||
@ -10,6 +11,8 @@ import aircox.settings as settings
 | 
			
		||||
 | 
			
		||||
from aircox.connector import Connector
 | 
			
		||||
 | 
			
		||||
logger = logging.getLogger('aircox.tools')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Streamer:
 | 
			
		||||
    """
 | 
			
		||||
@ -148,11 +151,15 @@ class Streamer:
 | 
			
		||||
        if not args:
 | 
			
		||||
            return
 | 
			
		||||
        self.process = subprocess.Popen(args, stderr=subprocess.STDOUT)
 | 
			
		||||
        atexit.register(self.process.terminate)
 | 
			
		||||
        atexit.register(lambda: self.process_terminate())
 | 
			
		||||
 | 
			
		||||
    def process_terminate(self):
 | 
			
		||||
        if self.process:
 | 
			
		||||
            self.process.terminate()
 | 
			
		||||
            logger.info("kill process {pid}: {info}".format(
 | 
			
		||||
                pid = self.process.pid,
 | 
			
		||||
                info = ' '.join(self.__get_process_args())
 | 
			
		||||
            ))
 | 
			
		||||
            self.process.kill()
 | 
			
		||||
            self.process = None
 | 
			
		||||
 | 
			
		||||
    def process_wait(self):
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ used to:
 | 
			
		||||
- cancels Diffusions that have an archive but could not have been played;
 | 
			
		||||
- run Liquidsoap
 | 
			
		||||
"""
 | 
			
		||||
import os
 | 
			
		||||
import time
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user