# Path: alignak_app/qobjects/threads/thread.py
# class BackendQThread(QThread):  # pylint: disable=too-few-public-methods
#     """
#         Class who create a QThread to trigger requests
#     """
# 
#     problem_states = ['CRITICAL', 'WARNING', 'UNKNOWN']
# 
#     def __init__(self, name, data=None):
#         super(BackendQThread, self).__init__()
#         self.name = name
#         self.data = data
# 
#     def run(self):  # pragma: no cover
#         """
#         Run the QThread. Trigger actions depending on the selected name
# 
#         """
# 
#         if app_backend.connected:
#             logger.debug('Launch a new thread request for backend: %s', self.name)
#             if 'user' in self.name:
#                 app_backend.query_user()
#             elif 'host' in self.name:
#                 app_backend.query_hosts()
#             elif 'service' in self.name:
#                 app_backend.query_services(self.data)
#             elif self.name in self.problem_states:
#                 app_backend.query_services_problems(self.name)
#             elif 'alignakdaemon' in self.name:
#                 app_backend.query_alignakdaemons()
#             elif 'livesynthesis' in self.name:
#                 app_backend.query_livesynthesis()
#             elif 'realm' in self.name:
#                 app_backend.query_realms()
#             elif 'timeperiod' in self.name:
#                 app_backend.query_timeperiods()
#             elif self.name == 'history':
#                 if self.data:
#                     app_backend.query_history(self.data['hostname'], self.data['host_id'])
#                 else:
#                     app_backend.query_history()
#             elif 'notifications' in self.name:
#                 app_backend.query_notifications()
#             else:
#                 logger.error("Thread is unknown: %s", self.name)
#         else:
#             logger.warning('The app is offline, the threads can not be launched !')
#             self.quit()


from logging import getLogger
from PyQt5.Qt import QObject
from alignak_app.qobjects.threads.thread import BackendQThread
                thread = BackendQThread(thread_name)
                thread.start()

                self.launched_threads[thread_type].append(
                    thread
                )
        else:
            for t_type in self.threads_to_launch:
                if not self.threads_to_launch[t_type]:
                    self.fill_threads(t_type)
                else:
                    thread_name = self.threads_to_launch[t_type].pop(0)
                    thread = BackendQThread(thread_name)
                    thread.start()

                    self.launched_threads[t_type].append(
                        thread
                    )

    def add_high_priority_thread(self, thread_name, data):
        """
        Launch a thread with higher priority (doesn't wait launch_threads() function)

        :param thread_name: name of priority thread
        :type thread_name: str
        :param data: data to give to thread for request
        :type data: dict
        """

        if len(self.high_threads) < 3:

# Path: alignak_app/qobjects/threads/thread.py
# class BackendQThread(QThread):  # pylint: disable=too-few-public-methods
#     """
#         Class who create a QThread to trigger requests
#     """
# 
#     problem_states = ['CRITICAL', 'WARNING', 'UNKNOWN']
# 
#     def __init__(self, name, data=None):
#         super(BackendQThread, self).__init__()
#         self.name = name
#         self.data = data
# 
#     def run(self):  # pragma: no cover
#         """
#         Run the QThread. Trigger actions depending on the selected name
# 
#         """
# 
#         if app_backend.connected:
#             logger.debug('Launch a new thread request for backend: %s', self.name)
#             if 'user' in self.name:
#                 app_backend.query_user()
#             elif 'host' in self.name:
#                 app_backend.query_hosts()
#             elif 'service' in self.name:
#                 app_backend.query_services(self.data)
#             elif self.name in self.problem_states:
#                 app_backend.query_services_problems(self.name)
#             elif 'alignakdaemon' in self.name:
#                 app_backend.query_alignakdaemons()
#             elif 'livesynthesis' in self.name:
#                 app_backend.query_livesynthesis()
#             elif 'realm' in self.name:
#                 app_backend.query_realms()
#             elif 'timeperiod' in self.name:
#                 app_backend.query_timeperiods()
#             elif self.name == 'history':
#                 if self.data:
#                     app_backend.query_history(self.data['hostname'], self.data['host_id'])
#                 else:
#                     app_backend.query_history()
#             elif 'notifications' in self.name:
#                 app_backend.query_notifications()
#             else:
#                 logger.error("Thread is unknown: %s", self.name)
#         else:
#             logger.warning('The app is offline, the threads can not be launched !')
#             self.quit()


# Path: alignak_app/qobjects/threads/threadmanager.py
from logging import getLogger
from PyQt5.Qt import QObject
from alignak_app.qobjects.threads.thread import BackendQThread

                thread = BackendQThread(thread_name)
                thread.start()

                self.launched_threads[thread_type].append(
                    thread
                )
        else:
            for t_type in self.threads_to_launch:
                if not self.threads_to_launch[t_type]:
                    self.fill_threads(t_type)
                else:
                    thread_name = self.threads_to_launch[t_type].pop(0)
                    thread = BackendQThread(thread_name)
                    thread.start()

                    self.launched_threads[t_type].append(
                        thread
                    )

    def add_high_priority_thread(self, thread_name, data):
        """
        Launch a thread with higher priority (doesn't wait launch_threads() function)

        :param thread_name: name of priority thread
        :type thread_name: str
        :param data: data to give to thread for request
        :type data: dict
        """

        if len(self.high_threads) < 3:

            backend_thread = BackendQThread(thread_name, data)