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