import logsupport
from logsupport import ConsoleWarning

HelperThreads = {}

class ThreadItem(object):
	def __init__(self, name, start, restart):
		self.name = name
		self.StartThread = start
		self.RestartThread = restart
		self.Thread = None

def CheckThreads():
	for T in HelperThreads.values():
		if not T.Thread.is_alive():
			logsupport.Logs.Log("Thread for: "+T.name+" died; restarting",severity=ConsoleWarning)
			T.RestartThread()

def StartThreads():
	for T in HelperThreads.values():
		T.StartThread()
		logsupport.Logs.Log("Starting helper thread for: ", T.name)



import logsupport
from logsupport import ConsoleWarning

HelperThreads = {}

class ThreadItem(object):
	def __init__(self, name, start, restart):
		self.name = name
		self.StartThread = start
		self.RestartThread = restart
		self.Thread = None

	def StopThread(self):
		self.Thread.stop()

def CheckThreads():
	for T in HelperThreads.values():
		if not T.Thread.is_alive():
			logsupport.Logs.Log("Thread for: "+T.name+" died; restarting",severity=ConsoleWarning)
			T.Thread = T.RestartThread(T)

def StartThreads():
	for T in HelperThreads.values():
		logsupport.Logs.Log("Starting helper thread for: ", T.name)
		T.Thread = T.StartThread()





Add a stop thread - may be needed for loss of heartbeat case
Add a stop thread - may be needed for loss of heartbeat case

  import logsupport
  from logsupport import ConsoleWarning
  
  HelperThreads = {}
  
  class ThreadItem(object):
  	def __init__(self, name, start, restart):
  		self.name = name
  		self.StartThread = start
  		self.RestartThread = restart
  		self.Thread = None
  
+ 	def StopThread(self):
+ 		self.Thread.stop()
+ 
  def CheckThreads():
  	for T in HelperThreads.values():
  		if not T.Thread.is_alive():
  			logsupport.Logs.Log("Thread for: "+T.name+" died; restarting",severity=ConsoleWarning)
- 			T.RestartThread()
+ 			T.Thread = T.RestartThread(T)
  
  def StartThreads():
  	for T in HelperThreads.values():
- 		T.StartThread()
  		logsupport.Logs.Log("Starting helper thread for: ", T.name)
+ 		T.Thread = T.StartThread()
  
  
  
+ 
+ 
Add a stop thread - may be needed for loss of heartbeat case
## Code Before:
import logsupport
from logsupport import ConsoleWarning

HelperThreads = {}

class ThreadItem(object):
	def __init__(self, name, start, restart):
		self.name = name
		self.StartThread = start
		self.RestartThread = restart
		self.Thread = None

def CheckThreads():
	for T in HelperThreads.values():
		if not T.Thread.is_alive():
			logsupport.Logs.Log("Thread for: "+T.name+" died; restarting",severity=ConsoleWarning)
			T.RestartThread()

def StartThreads():
	for T in HelperThreads.values():
		T.StartThread()
		logsupport.Logs.Log("Starting helper thread for: ", T.name)



## Instruction:
Add a stop thread - may be needed for loss of heartbeat case
## Code After:
import logsupport
from logsupport import ConsoleWarning

HelperThreads = {}

class ThreadItem(object):
	def __init__(self, name, start, restart):
		self.name = name
		self.StartThread = start
		self.RestartThread = restart
		self.Thread = None

	def StopThread(self):
		self.Thread.stop()

def CheckThreads():
	for T in HelperThreads.values():
		if not T.Thread.is_alive():
			logsupport.Logs.Log("Thread for: "+T.name+" died; restarting",severity=ConsoleWarning)
			T.Thread = T.RestartThread(T)

def StartThreads():
	for T in HelperThreads.values():
		logsupport.Logs.Log("Starting helper thread for: ", T.name)
		T.Thread = T.StartThread()




