Cleanup to help with SAAS-714

This commit is contained in:
Albert Santoni 2015-05-19 12:02:19 -04:00
parent aee5615cd3
commit add211d13c
1 changed files with 7 additions and 11 deletions

View File

@ -3,12 +3,8 @@ import json
import logging import logging
import collections import collections
import Queue import Queue
import subprocess
import multiprocessing
import time import time
import sys
import traceback import traceback
import os
import pickle import pickle
import threading import threading
from urlparse import urlparse from urlparse import urlparse
@ -158,23 +154,23 @@ class StatusReporter():
''' We use multiprocessing.Process again here because we need a thread for this stuff ''' We use multiprocessing.Process again here because we need a thread for this stuff
anyways, and Python gives us process isolation for free (crash safety). anyways, and Python gives us process isolation for free (crash safety).
''' '''
_ipc_queue = multiprocessing.Queue() _ipc_queue = Queue.Queue()
#_request_process = multiprocessing.Process(target=process_http_requests, #_http_thread = multiprocessing.Process(target=process_http_requests,
# args=(_ipc_queue,)) # args=(_ipc_queue,))
_request_process = None _http_thread = None
@classmethod @classmethod
def start_thread(self, http_retry_queue_path): def start_thread(self, http_retry_queue_path):
StatusReporter._request_process = threading.Thread(target=process_http_requests, StatusReporter._http_thread = threading.Thread(target=process_http_requests,
args=(StatusReporter._ipc_queue,http_retry_queue_path)) args=(StatusReporter._ipc_queue,http_retry_queue_path))
StatusReporter._request_process.start() StatusReporter._http_thread.start()
@classmethod @classmethod
def stop_thread(self): def stop_thread(self):
logging.info("Terminating status_reporter process") logging.info("Terminating status_reporter process")
#StatusReporter._request_process.terminate() # Triggers SIGTERM on the child process #StatusReporter._http_thread.terminate() # Triggers SIGTERM on the child process
StatusReporter._ipc_queue.put("shutdown") # Special trigger StatusReporter._ipc_queue.put("shutdown") # Special trigger
StatusReporter._request_process.join() StatusReporter._http_thread.join()
@classmethod @classmethod
def _send_http_request(self, request): def _send_http_request(self, request):