def __init__(self):
QtCore.QThread.__init__(self)
self.mutex = QtCore.QMutex()
self.pack_opener = None
self._isRunning = False
python类QThread()的实例源码
def __init__(self, scene_model, *args, **kwargs):
QtCore.QObject.__init__(self, *args, **kwargs)
self.worker_thread = QtCore.QThread()
self.moveToThread(self.worker_thread)
self.worker_thread.start()
self.model = None
self.log = SceneLogModel(self)
self.sources = SourceModel(self)
self._log_handler = logging.Handler()
self._log_handler.emit = self.sigLogRecord.emit
self.cursor_tracker = CursorTracker()
self.setModel(scene_model)
def __init__(self):
QtCore.QObject.__init__(self)
self.scene = None
self.frame = None
self.quadtree = None
self.covariance = None
self.log = SceneLogModel(self)
self._ = SignalProxy(self._sigQuadtreeChanged,
rateLimit=5,
delay=0,
slot=lambda: self.sigQuadtreeChanged.emit())
self._log_handler = logging.Handler()
self._log_handler.emit = self.sigLogRecord.emit
self.qtproxy = QSceneQuadtreeProxy(self)
self.worker_thread = QtCore.QThread()
self.moveToThread(self.worker_thread)
self.worker_thread.start()
def __init__(self, search_coord, type_, min_points, max_points, min_range, max_range, world_data):
QtCore.QThread.__init__(self)
self.search_coord = search_coord
self.type_ = type_
self.min_points = min_points
self.max_points = max_points
self.min_range = min_range
self.max_range = max_range
self.world_data = world_data
def __init__(self, table_data):
QtCore.QThread.__init__(self)
self.table_data = table_data
def __init__(self, table_data, option, number, player, points):
QtCore.QThread.__init__(self)
self.table_data = table_data
self.option = option
self.number = number
self.player = player
self.points = points
def __init__(self, url):
QtCore.QThread.__init__(self)
self.url = url
def __init__(self, world_speed, unit_speed, origin, destination, unit, arrival):
QtCore.QThread.__init__(self)
self.world_speed = world_speed
self.unit_speed = unit_speed
self.origin = origin
self.destination = destination
self.unit = unit
self.arrival = arrival
def __init__(self, servers_json_path):
QtCore.QThread.__init__(self)
self.servers_json_path = servers_json_path
def __init__(self, session, parent=None):
QtCore.QThread.__init__(self, parent)
self.session = session
self.file_path = None
self.incoming_file = ()
def load(self, file_path):
self.file_path = file_path
if file_path.endswith(".ag"):
self.incoming_file = (file_path, 'SESSION')
else:
file_type = androconf.is_android(file_path)
self.incoming_file = (file_path, file_type)
self.start(QtCore.QThread.LowestPriority)
def __init__(self, session, parent=None):
QtCore.QThread.__init__(self, parent)
self.session = session
self.file_path = None
self.incoming_file = ()
def load(self, file_path):
self.file_path = file_path
if file_path.endswith(".ag"):
self.incoming_file = (file_path, 'SESSION')
else:
file_type = androconf.is_android(file_path)
self.incoming_file = (file_path, file_type)
self.start(QtCore.QThread.LowestPriority)
def __init__(self, opts):
QtCore.QThread.__init__(self)
self.mutex = QtCore.QMutex()
self.opts = opts
self.email, self.password = "", ""
self.anonymous = True
def __init__(self, widget, method_name, parent=None):
QtCore.QThread.__init__(self, parent)
self.widget = widget
self.method_name = method_name
def __init__(self, first, last, node, gui):
QtCore.QThread.__init__(self)
self.first = first
self.last = last
self.node = node
self.gui = gui
def startClipboardThread(self):
self.clipboard_thread = QtCore.QThread()
self.clipThread = ClipThread(self)
self.clipThread.moveToThread(self.clipboard_thread)
self.clipboard_thread.started.connect(self.clipThread.process)
self.clipThread.copied.connect(self.handleClipboard)
self.clipboard_thread.start()
def __init__(self, site, niche, q,
start_pg, max_pgs, winlock, predictor):
QtCore.QThread.__init__(self)
self.site = site
self.niche = niche
self.q = q
self.start_pg = start_pg
self.max_pgs = max_pgs
self.winlock = winlock
self.exit_flag = False
self.exit_ready = False
self.pred = predictor
def __init__(self):
QtCore.QThread.__init__(self)
def __init__(self):
QtCore.QThread.__init__(self)
def __init__(self, parent=None):
QtCore.QThread.__init__(self, parent)
self.apk_path = None
self.session_path = None
def load(self, apk_path):
self.apk_path = apk_path
if apk_path.endswith(".apk"):
self.session_path = self.apk_path[:-4] + '.ag'
elif apk_path.endswith(".ag"):
self.session_path = apk_path
else:
return
self.start(QtCore.QThread.LowestPriority)
def __init__(self, parent=None):
QtCore.QThread.__init__(self, parent)
self.apk_path = None
self.session_path = None
def load(self, apk_path):
self.apk_path = apk_path
if apk_path.endswith(".apk"):
self.session_path = self.apk_path[:-4] + '.ag'
elif apk_path.endswith(".ag"):
self.session_path = apk_path
else:
return
self.start(QtCore.QThread.LowestPriority)
def __init__(self, hostname, workerFunction, messageQueue,
n_threads = None, cachepath = None, qsubHeader=None ):
"""
def __init__(self, hostname, workerFunction, messageQueue,
n_threads = None, cachepath = None, qsubHeader=None )
hostName is any string that ID's the host uniquely
workerFunction is one of ['local','qsub', 'rsync', 'archive'], reflecting what the host should do.
messageQueue is the message queue from the skulkManager
n_threads is the number of p-threads to use for the job.
qsubHeader is a text file that contains everything but the qsub line for a .bash script.
"""
# In case I need to re-factor to have a seperate thread for each host
#QtCore.QThread.__init__(self)
# self.sleepTime = 1.0
self.hostName = hostname
self.messageQueue = messageQueue
self.zorroState = None
self.submitName = None
# CANNOT get an instantiated object here so we cannot pass in bound function handles directly, so
# we have to use strings instead.
if workerFunction == 'local':
self.workerFunction = self.submitLocalJob
elif workerFunction == 'dummy':
self.workerFunction = self.submitDummyJob
elif workerFunction == 'qsub':
self.workerFunction = self.submitQsubJob
elif workerFunction == 'rsync':
self.workerFunction = self.submitRsyncJob
elif workerFunction == 'archive':
self.workerFunction = self.submitArchiveJob
else:
self.workerFunction = workerFunction
self.subprocess = None
self.n_threads = n_threads
self.cachePath = cachepath
self.qsubHeaderFile = qsubHeader
def __init__(self, inputQueue=None ):
QtCore.QThread.__init__(self)
self.verbose = 3
self.DEBUG = False
# Processible file extensions
self.globPattern = ['*.dm4', '*.dm3', '*.mrc', '*.mrcz', '*.tif', '*.tiff',
'*.mrcs', '*.mrcsz', '*.hdf5', '*.h5', '*.bz2', '*.gz', '*.7z' ]
# Default object for copying the parameters (also accessed by Automator)
self.zorroDefault = zorro.ImageRegistrator()
# Mutex-protected queues of the image stacks to be worked on
self.__globalHeap = skulkHeap()
self.__newHeap = skulkHeap()
self.__syncHeap = skulkHeap()
self.__procHeap = skulkHeap()
self.__archiveHeap = skulkHeap()
self.completedCount = 0
# Messages from the hosts to the skulkManager (i.e. I've finished, or, I've fallen and I can't get up again)
# This is unidirectional from the hosts to the skulk manager
self.messageQueue = queue.Queue(maxsize=0)
# Servers that will accept jobs, is a dict of skulkHosts
self.procHosts = {}
self.syncHosts = {}
self.archiveHosts = {}
# Path manager, for keeping real and normed paths manageable.
self.paths = skulkPaths()
# TODO: Do we want Paramiko for running remote jobs via SSH? Or restrict ourselves to qsub locally?
# https://github.com/paramiko/paramiko
# It's not in Anaconda by default, but it's in both conda and pip
self.__STOP_POLLING = False
# bytes, should be bigger than Digital Micrograph header size, but smaller than any conceivable image
self.sleepTime = 1.0
pass