本文整理汇总了Python中threading.Thread.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.__init__方法的具体用法?Python Thread.__init__怎么用?Python Thread.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, function, sleep=30):
Thread.__init__(self)
self.daemon = True
self.sleepTime = sleep
self.runTimer = True
self.function = function
示例2: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, interval_sec, get_connection_holders):
Thread.__init__(self, name="Connection heartbeat")
self._interval = interval_sec
self._get_connection_holders = get_connection_holders
self._shutdown_event = Event()
self.daemon = True
self.start()
示例3: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, req, proxy, logger, task, exit_check=None, ignored_errors=[]):
Thread.__init__(self, name = "monitor%s" % task.guid)
Thread.setDaemon(self, True)
# the count of votes per error code
self.vote_result = {}
# the error code to be ignored
self.vote_cleared = set().union(ignored_errors)
self.thread_last_seen = {}
self.dctlock = RLock()
self.votelock = RLock()
self.thread_ref = {}
self.thread_zombie = set()
# HttpReq instance
self.req = req
# proxy.Pool instance
self.proxy = proxy
self.logger = logger
self.task = task
self._exit = exit_check if exit_check else lambda x: False
self._cleaning_up = False
if os.name == "nt":
self.set_title = lambda s:os.system("TITLE %s" % (
s if PY3K else s.encode(CODEPAGE, 'replace')))
elif os.name == 'posix':
import sys
self.set_title = lambda s:sys.stdout.write("\033]2;%s\007" % (
s if PY3K else s.encode(CODEPAGE, 'replace')))
示例4: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, name, event, function, args=[], period = 5.0):
Thread.__init__(self)
self.name = name
self.stopped = event
self.period = period
self.function = function
self.args = args
示例5: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, prompt="> ", stdin=None, stdout=None):
if _debug: ConsoleCmd._debug("__init__")
cmd.Cmd.__init__(self, stdin=stdin, stdout=stdout)
Thread.__init__(self, name="ConsoleCmd")
# check to see if this is running interactive
self.interactive = sys.__stdin__.isatty()
# save the prompt for interactive sessions, otherwise be quiet
if self.interactive:
self.prompt = prompt
else:
self.prompt = ''
# gc counters
self.type2count = {}
self.type2all = {}
# logging handlers
self.handlers = {}
# set a INT signal handler, ^C will only get sent to the
# main thread and there's no way to break the readline
# call initiated by this thread - sigh
if hasattr(signal, 'SIGINT'):
signal.signal(signal.SIGINT, console_interrupt)
# start the thread
self.start()
示例6: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, params):
Thread.__init__(self)
self.tid = params['tid'] #work线程id
self.apns_gateway = ApnsGateway(certfile=params['certfile'], #apns连接
host=params['host'],
port=params['port'],
retry=params['retry'])
示例7: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, config, pipe_name=PIPE):
"""@param pipe_name: Cuckoo PIPE server name."""
Thread.__init__(self)
self.pipe_name = pipe_name
self.config = config
self.options = config.get_options()
self.do_run = True
示例8: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self):
Thread.__init__(self)
self.daemon = True
# flush the input buffer
ser.read(1000)
示例9: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, app, baseurl, mount, cacertdir = "/etc/grid-security/certificates", minreq = 1000, interval = 300, instance = "test"):
Thread.__init__(self, name = "LdapSync")
self.sectoken = "".join(random.sample(string.letters, 30))
self._inturl = "http://localhost:%d%s/%s/ldapsync" % \
(app.srvconfig.port, mount, instance)
self._headers = \
fake_authz_headers(open(app.srvconfig.tools.cms_auth.key_file).read(),
method = "Internal", login = self.sectoken,
name = self.__class__.__name__, dn = None,
roles = {"Global Admin": {"group": ["global"]}}) \
+ [("Accept", "application/json")]
self._cv = Condition()
if isinstance(baseurl, str):
self._baseurl = baseurl
self._cacertdir = cacertdir
self._minreq = minreq
self._interval = interval
self._stopme = False
self._full = (0, [], [])
self._warnings = {}
self._intreq = RequestManager(num_connections = 2,
user_agent = self._ident,
handle_init = self._handle_init,
request_respond = self._respond,
request_init = self._int_init)
cherrypy.engine.subscribe("stop", self.stop)
cherrypy.engine.subscribe("start", self.start)
示例10: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, sock):
Thread.__init__(self)
self.sendingQueue = Utils.globals.sendingQueue
self.sock = sock
self.ping = ""
self.outfile = open("data_received_from_node.txt", 'w')
示例11: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self):
Thread.__init__(self)
self.daemon = True
self.start()
self.status = ''
self._sleep_time = 0
示例12: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, proxy, url, file):
Thread.__init__(self)
self.proxy = proxy
self.url = url
self.file = file
self.result = False
self.data = ""
示例13: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, sensor_name, sensor_type, serial):
Thread.__init__(self)
if sensor_name[-1] == '/':
sensor_name = sensor_name[:-1]
if (sensor_type == "Kinect2") or (sensor_type == "Kinectv2") or (sensor_type == "Kinect_v2"):
self.kinect_type = "Kinect2"
print "Loading Kinect2 with serial : "+serial
self.kinect = Kinect_v2(sensor_name,serial,queue_size=10,compression=False,use_rect=True,use_ir=True)
elif (sensor_type == "Kinect") or (sensor_type == "Kinect1") or (sensor_type == "Kinectv1") or (sensor_type == "Kinect_v1"):
self.kinect_type = "Kinect1"
print "Loading "+sensor_name+" of type Kinect1"
self.kinect = Kinect(sensor_name,queue_size=10,compression=False,use_rect=True,use_depth_registered=True,use_ir=False)
else:
print "ERROR: Sensor type must be Kinect2 or Kinect"
return
self.sensor_name = sensor_name
self.kinect.wait_until_ready()
self.listener = tf.TransformListener()
self.list_robot_links = ['link_0','link_1','link_2','link_3','link_4','link_5','link_6','link_7']
self.last_pose = None
rospy.Subscriber("/kinect_merge/tracking_state", MarkerArray , self.callback)
示例14: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, files, outDir, dirFormat, fileFormat,
anon=dict(), keep_filename=False, iterator=None,
test=False, listener=None, total=None, root=None, seriesFirst=False):
self.dirFormat = dirFormat
self.fileFormat = fileFormat
self.fileList = files
self.anondict = anon
self.keep_filename = keep_filename
self.seriesFirst = seriesFirst
self.outDir = outDir
self.test = test
self.iter = iterator
self.root = root
if not isinstance(self.fileList, tuple):
self.fileList = (self.fileList,)
if total is None:
self.total = len(self.fileList)
else:
self.total = total
self.isgui = False
if listener:
self.listener = listener
self.isgui = True
Thread.__init__(self)
self.start()
示例15: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import __init__ [as 别名]
def __init__(self, model=None, ishome=False):
IdleObject.__init__(self)
Thread.__init__(self)
self.model = model
self.ishome = ishome
self.daemon = True
self.stop = False