本文整理汇总了Python中threading.Thread.sleep方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.sleep方法的具体用法?Python Thread.sleep怎么用?Python Thread.sleep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.sleep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCurrentPos
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import sleep [as 别名]
def getCurrentPos(self, event):
global mode
print('Start to Get mouse pos')
mode = 4
Thread.sleep(3000)
print('Get mouse pos')
mouse_pos = Env.getMouseLocation()
print('Current mouse pos: x:' + mouse_pos.x + ' y:' + mouse_pos.y)
示例2: run
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import sleep [as 别名]
def run(self):
""" generated source for method run """
s = File.separator
myTempFolder = self.app.tempFolder + s + self.dmsId()
myAppFolder = self.app.appFolder + s + self.dmsId()
openDir = File(myTempFolder + s + "open_" + self.userId())
name = str()
newName = str()
baseName = str()
ext = str()
newExt = str()
itemId = str()
currentMd5 = str()
cacheMd5 = str()
n = str()
uploadContentType = ""
storedMtime = long()
currentMtime = long()
file_ = File()
dir = File()
tmp = File()
tmp2 = File()
delta = File()
upload = None
files = []
in_ = FileInputStream()
out = FileOutputStream()
uploadSuccess = bool()
uploadRet = HashMap()
uploadErrorCount = 0
tmpFileSize = long()
if not openDir.isDirectory():
return
while True:
try:
Thread.sleep(1000)
except InterruptedException as e:
Thread.currentThread().interrupt()
return
if openDir.isDirectory() == False:
continue
files = openDir.listFiles()
while len(files):
dir = files[i]
if dir.isDirectory():
itemId = dir.__name__
newName = ""
newExt = ""
# load info
if openInfo == None or openInfo.isEmpty():
if dir.lastModified() < System.currentTimeMillis() - 1000 * 60 * 60:
print "no open file info found for " + itemId
self.app.deleteOpenItem(itemId)
if dir.exists():
dir.setLastModified(System.currentTimeMillis())
continue
if cacheInfo == None or cacheInfo.isEmpty():
print "no cache info found for " + itemId
self.app.deleteOpenItem(itemId)
continue
storedMtime = Long.parseLong(openInfo.get("mtime") + "")
name = str(openInfo.get("name"))
baseName = name.substring(0, name.lastIndexOf(".")) if name.lastIndexOf(".") > -1 else name
ext = name.substring(name.lastIndexOf(".") + 1, len(name)) if name.lastIndexOf(".") > -1 else ""
file_ = File(myTempFolder + s + "open_" + self.userId() + s + itemId + s + name)
if not ext == "" and File(file_.getAbsolutePath() + "x").exists():
# file name has changed to docx, xlsx, enz
newName = name + "x"
newExt = newName.substring(newName.lastIndexOf(".") + 1, len(newName))
if not newExt == "" and not newExt == ext and (not openInfo.containsKey("readOnly") or not openInfo.get("readOnly") == "true"):
# file extension has changed on writable document
self.app.getTransponderLine("action=alterItemExtension&itemId=" + itemId + "&ext=" + newExt)
if not newName == "" and not newName == name:
# name has changed
openInfo.put("name", newName)
FileActions.saveHashMap(openInfo, myTempFolder + s + "open_" + self.userId() + s + itemId + ".json")
file_ = File(myTempFolder + s + "open_" + self.userId() + s + itemId + s + newName)
name = newName
if not file_.exists():
continue
if not openInfo.containsKey("readOnly") or not openInfo.get("readOnly") == "true":
# lock or refresh lock if autoLocking is on and item is not read-only
if openInfo.containsKey("expectFileLock") and not openInfo.get("expectFileLock") == "no":
fileIsLocked = FileActions.isLockedByFileSystem(file_) if openInfo.get("expectFileLock") == "fileSystem" else FileActions.isLockedByTmpFile(file_)
# files that are locked by the client when opened
if fileIsLocked and (lock == None or not lock.containsKey("userId") or not lock.get("userId") == self.userId() or Long.parseLong(lock.get("stamp") + "") < System.currentTimeMillis() - 4 * 60 * 1000):
# lock item if not locked or not locked by me or lock is old
self.app.lockItem(itemId)
elif not fileIsLocked and lock != None and lock.containsKey("userId") and lock.get("userId") == self.userId():
# unlock if file is not locked and current lock is mine
self.app.unlockItem(itemId)
deleteItem = True
elif (not openInfo.containsKey("expectFileLock") or not openInfo.get("expectFileLock") == "tmpFile") and FileActions.isLockedByTmpFile(file_):
print "update track file locking by temp file"
openInfo.put("expectFileLock", "tmpFile")
FileActions.saveHashMap(openInfo, myTempFolder + s + "open_" + self.userId() + s + itemId + ".json")
if openInfo.containsKey("readOnly") and openInfo.get("readOnly") == "true" and openInfo.containsKey("expectFileLock") and not openInfo.get("expectFileLock") == "no":
# read only docs can alsow be deleted when lock is lifted
fileIsLocked = FileActions.isLockedByFileSystem(file_) if openInfo.get("expectFileLock") == "fileSystem" else FileActions.isLockedByTmpFile(file_)
if not fileIsLocked:
#.........这里部分代码省略.........