Python threading.Thread.__init__() Examples

The following are 30 code examples of threading.Thread.__init__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module threading.Thread , or try the search function .
Example #1
Source File: logger.py    From TradzQAI with Apache License 2.0 7 votes vote down vote up
def __init__(self):

        self.path = "logs/"

        self.names = []

        self.logs = {}
        self.id = {}
        self.current_index = {}

        self.log_file_name = {}
        self.log_file = {}
        self.log_path = ""
        self.log_file_path = {}

        self._running = False
        self.event = None

        Thread.__init__(self) 
Example #2
Source File: SSH.py    From im with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, host, user, passwd=None, private_key=None, port=22, proxy_host=None):
        # Atributo para la version "thread"
        self.thread = None

        self.proxy_host = proxy_host
        self.tty = False
        self.port = port
        self.host = host
        self.username = user
        self.password = passwd
        self.private_key = private_key
        self.private_key_obj = None
        if (private_key is not None and private_key.strip() != ""):
            private_key_obj = StringIO()
            if os.path.isfile(private_key):
                pkfile = open(private_key)
                for line in pkfile.readlines():
                    private_key_obj.write(line)
                pkfile.close()
            else:
                private_key_obj.write(private_key)

            private_key_obj.seek(0)
            self.private_key_obj = paramiko.RSAKey.from_private_key(
                private_key_obj) 
Example #3
Source File: instrument_srs.py    From gdb_python_api with MIT License 6 votes vote down vote up
def __init__(self, base_addr, size):
        Thread.__init__(self)
        self.base_addr = base_addr  # the vector we are monitoring
        self.size = size            # its size
        self.messages = Queue()     # cross-thread communication
        # store contents of vec
        self.values = []
        int_t = gdb.lookup_type('int')
        for idx in range(0, size):
            self.values.append(int((base_addr + idx).dereference().cast(int_t)))
        self.animations = []

    # Front end code
    # These methods run in the gdb thread in response to breakpoints,
    # and accept gdb.Value objects

    # Updates for instrumented actions 
Example #4
Source File: rmThreadWatcher.py    From rainmachine-developer-resources with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        Thread.__init__(self)
        self.__running = False
        self.__lock = Lock()
        self.__data = {} # key=threadId, value={timeoutHint: timestamp, lastUpdate: timestamp}

        self.__watchDogFile = "/dev/watchdog"
        self.__watchDogDescriptor = None
        self.__watchDogTimeout = 5

        self.__lastWatchdogTimestamp = None
        self.__lastCheckTimestamp = None
        self.__lastNoneIpTimestamp = None
        self.__pause = False

        self.__wifiRefreshTimeout = 60 * 2
        self.__wifiNoneIpTimeout = 60 * 1
        self.__systemTimeChangeThreshold = 60 * 10 # on which system time change(ntpd) threshold we should reset

        self.__mainManager = None

    #----------------------------------------------------------------------------------------
    #
    #
    # 
Example #5
Source File: rmParserThread.py    From rainmachine-developer-resources with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        Thread.__init__(self)

        self.__simulator = None
        self.__parserManager = None
        self.__mixerDataTable = None

        self.__useThreading = False
        if self.__useThreading:
            self.__stop = False
            self.__waitTimeout = 3600
            self.__messageQueue = Queue()

    #----------------------------------------------------------------------------------------
    #
    #
    # 
Example #6
Source File: Udp_server.py    From rtp_cluster with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self, laddress, data_callback, family = None, o = None):
        if o == None:
            if family == None:
                if laddress != None and laddress[0].startswith('['):
                    family = socket.AF_INET6
                    laddress = (laddress[0][1:-1], laddress[1])
                else:
                    family = socket.AF_INET
            self.family = family
            self.laddress = laddress
            self.data_callback = data_callback
        else:
            self.laddress, self.data_callback, self.family, self.nworkers, self.flags, \
              self.ploss_out_rate, self.pdelay_out_max, self.ploss_in_rate, \
              self.pdelay_in_max = o.laddress, o.data_callback, o.family, \
              o.nworkers, o.flags, o.ploss_out_rate, o.pdelay_out_max, o.ploss_in_rate, \
              o.pdelay_in_max 
Example #7
Source File: mysql_repl_repair.py    From mysql_repl_repair with Apache License 2.0 6 votes vote down vote up
def __init__(self,user,password,socket,logdir,isdebug):
		Thread.__init__(self)

		self.user = user
		self.password = password
		self.socket = socket
		self.logdir = logdir
		self.isdebug = isdebug
		self.errorno = 0

		self.dbcursor = self.init_dbconn()
		self.port = self.init_port()

		self.start_position = 0
		self.stop_position = 0

		self.lockfile = "/tmp/mysql_repl_repair" + str(self.port) + ".lck"

		self.logger = MyLogger(self.port, self.logdir, self.isdebug)

		self.logger.info("*"*64)
		self.logger.info(" "*25 + "PROCESS START")
		self.logger.info("*"*64) 
Example #8
Source File: Misc.py    From pcocc with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, num_threads):
        self.tasks = Queue()
        self.retq = Queue()
        self.exception = None
        self.num_tasks = 0

        for _ in range(num_threads):
            Worker(self) 
Example #9
Source File: basenji_sad.py    From basenji with Apache License 2.0 5 votes vote down vote up
def __init__(self, snp_queue, sad_out, stats, log_pseudo=1):
    Thread.__init__(self)
    self.queue = snp_queue
    self.daemon = True
    self.sad_out = sad_out
    self.stats = stats
    self.log_pseudo = log_pseudo 
Example #10
Source File: basenji_train1.py    From basenji with Apache License 2.0 5 votes vote down vote up
def __init__(self, acc_queue):
    Thread.__init__(self)
    self.queue = acc_queue
    self.daemon = True 
Example #11
Source File: auto_dataset.py    From aetros-cli with MIT License 5 votes vote down vote up
def __init__(self, q, progress, dataset, max, images, controller):
        Thread.__init__(self)
        self.q = q
        self.progress = progress
        self.dataset = dataset
        self.max = max
        self.images = images
        self.controller = controller 
Example #12
Source File: SSH.py    From im with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, ssh):
        Thread.__init__(self)

        self.ssh = ssh
        self.command = None
        self.command_return = None
        self.client = None
        self.proxy = None 
Example #13
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        Thread.__init__(self) 
Example #14
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,groupname):
        self.groupname=groupname
        Thread.__init__(self) 
Example #15
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, name, url, data_path):
        self.data = url
        self.path = data_path
        Thread.__init__(self) 
Example #16
Source File: auto_dataset.py    From aetros-cli with MIT License 5 votes vote down vote up
def __init__(self, datagen, images, classes_count, batch_size):
        self.index = -1
        self.datagen = datagen
        self.images = images
        random.shuffle(self.images)
        self.lock = Lock()

        self.classes_count = classes_count
        self.batch_size = batch_size 
Example #17
Source File: MonitorThread.py    From aetros-cli with MIT License 5 votes vote down vote up
def __init__(self, job_backend, cpu_cores=1, gpu_devices=None, docker_container=None):
        Thread.__init__(self)

        self.job_backend = job_backend
        self.gpu_devices = gpu_devices
        self.docker_container = docker_container
        self.max_minutes = 0
        self.cpu_cores = cpu_cores

        job = self.job_backend.job
        if 'maxTime' in job['config'] and isinstance(job['config']['maxTime'], int) and job['config']['maxTime'] > 0:
            self.max_minutes = job['config']['maxTime']

        self.hardware_stream = self.job_backend.git.stream_file('aetros/job/monitoring.csv')

        header = ["second", "cpu", "memory"]
        try:
            if self.gpu_devices:
                for gpu_id, gpu in enumerate(aetros.cuda_gpu.get_ordered_devices()):
                    if gpu_id in gpu_devices:
                        header.append("memory_gpu" + str(gpu['id']))
        except aetros.cuda_gpu.CudaNotImplementedException: pass

        if job_backend.get_job_model().has_dpu():
            header += ['dpu0']

        self.hardware_stream.write(simplejson.dumps(header)[1:-1] + "\n")
        self.running = True
        self.early_stopped = False
        self.handle_max_time = True
        self.client = docker.from_env()
        self.docker_api = docker.APIClient(**docker.utils.kwargs_from_env())
        self.stat_stream = None

        self.docker_last_last_reponse = None
        self.docker_last_stream_data = 0
        self.docker_last_mem = None
        self.docker_last_cpu = None 
Example #18
Source File: lights_cloud_test.py    From Reinforcement_Learning_for_Traffic_Light_Control with Apache License 2.0 5 votes vote down vote up
def __init__(self, group=None, target=None, name=None,
                 args=(), kwargs={}, Verbose=None):
        Thread.__init__(self, group, target, name, args, kwargs)
        self._return = None 
Example #19
Source File: loggingcontrols.py    From flumine with MIT License 5 votes vote down vote up
def __init__(self, daemon: bool = True):
        Thread.__init__(self, daemon=daemon, name=self.NAME)
        self.logging_queue = queue.Queue()
        self.cache = [] 
Example #20
Source File: util.py    From apio with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, outcallback=None):
        Thread.__init__(self)
        self.outcallback = outcallback

        self._fd_read, self._fd_write = os.pipe()
        self._pipe_reader = os.fdopen(self._fd_read)
        self._buffer = []

        self.start() 
Example #21
Source File: intervention.py    From cassandra-dtest with Apache License 2.0 5 votes vote down vote up
def __init__(self, node):
        Thread.__init__(self)
        self.node = node 
Example #22
Source File: intervention.py    From cassandra-dtest with Apache License 2.0 5 votes vote down vote up
def __init__(self, node, tablename, filename='debug.log', delay=0):
        Thread.__init__(self)
        self.node = node
        self.tablename = tablename
        self.filename = filename
        self.delay = delay
        self.mark = node.mark_log(filename=self.filename) 
Example #23
Source File: intervention.py    From cassandra-dtest with Apache License 2.0 5 votes vote down vote up
def __init__(self, node):
        Thread.__init__(self)
        self.node = node 
Example #24
Source File: topology_test.py    From cassandra-dtest with Apache License 2.0 5 votes vote down vote up
def __init__(self, node):
        Thread.__init__(self)
        self.node = node 
Example #25
Source File: mysql_repl_repair.py    From mysql_repl_repair with Apache License 2.0 5 votes vote down vote up
def __init__(self, tag, logdir=None, isdebug=False):
		self.log = logging.getLogger("MYSQLREPLREPAIR" + str(tag))

		self.logdir = logdir
		self.isdebug = isdebug
		self.tag = tag

		self.config_logger() 
Example #26
Source File: mysql_repl_repair.py    From mysql_repl_repair with Apache License 2.0 5 votes vote down vote up
def __init__(self, option):
		self.option = option 
Example #27
Source File: mysql_repl_repair2.py    From mysql_repl_repair with Apache License 2.0 5 votes vote down vote up
def __init__(self, tag, logdir=None, isdebug=False):
		self.log = logging.getLogger("MYSQLREPLREPAIR" + str(tag))

		self.logdir = logdir
		self.isdebug = isdebug
		self.tag = tag

		self.config_logger() 
Example #28
Source File: mysql_repl_repair2.py    From mysql_repl_repair with Apache License 2.0 5 votes vote down vote up
def __init__(self,user,password,ip,port,logdir,isdebug):
		Thread.__init__(self)

		self.user = user
		self.password = password
		self.ip = ip
		self.port = port
		self.logdir = logdir
		self.isdebug = isdebug
		self.errorno = 0
		self.dbcursor = self.dbconn(self.ip, self.port).cursor()
		self.lockfile = "/tmp/mysql_repl_repair." + ip + "." + port + ".lck"
		self.logger = MyLogger(self.ip+"."+self.port, self.logdir, self.isdebug) 
Example #29
Source File: mysql_repl_repair2.py    From mysql_repl_repair with Apache License 2.0 5 votes vote down vote up
def __init__(self, option):
		self.option = option 
Example #30
Source File: tensorboard_handle.py    From dataiku-contrib with Apache License 2.0 5 votes vote down vote up
def __init__(self, folder_name, host="127.0.0.1", verbosity=logging.WARN):
        Thread.__init__(self)
        self.project_key = os.environ["DKU_CURRENT_PROJECT_KEY"]
        self.folder_name = folder_name
        self.client = dataiku.api_client()

        logging.set_verbosity(verbosity)

        # Getting app
        logs_path = self.__get_logs_path()
        app = self.__get_tb_app(logs_path)

        # Setting server
        self.srv = make_server(host, 0, app)