Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Popen无法在带有time.sleep的Windows上运行_Python_Multithreading_Wxpython_Schema_Popen - Fatal编程技术网

Python Popen无法在带有time.sleep的Windows上运行

Python Popen无法在带有time.sleep的Windows上运行,python,multithreading,wxpython,schema,popen,Python,Multithreading,Wxpython,Schema,Popen,我试图使用下面的代码示例来检查模式文件是否存在,如果不存在,我将启动一个线程,在打开下载新模式文件的第二个窗口时使用Popen下载新模式文件。请稍等。。在关闭第二个窗口之前,使用time.sleep0.5等待文件下载。这一切在MacOSX上都可以正常工作,但在windows中,它会打开下载新模式文件的第二个窗口。请稍等。但是没有下载模式文件就冻结了,然后我需要将其崩溃。 由于它在Mac上工作,我能做些什么使它在两个操作系统上都工作 def schemaVersionCheck(self, Ver

我试图使用下面的代码示例来检查模式文件是否存在,如果不存在,我将启动一个线程,在打开下载新模式文件的第二个窗口时使用Popen下载新模式文件。请稍等。。在关闭第二个窗口之前,使用time.sleep0.5等待文件下载。这一切在MacOSX上都可以正常工作,但在windows中,它会打开下载新模式文件的第二个窗口。请稍等。但是没有下载模式文件就冻结了,然后我需要将其崩溃。 由于它在Mac上工作,我能做些什么使它在两个操作系统上都工作

def schemaVersionCheck(self, Version):
    foundSchemaFile = False
    for rngFile in os.listdir("."):
        if rngFile.endswith(".rng"):
            foundSchemaFile = True
            if rngFile != self.schemaFile:
                foundSchemaFile = False

    if foundSchemaFile == False:
        threading.Thread(target=self.getNewSchema, args=(Version, )).start()
        msg = "Downloading new schema file. Please wait."
        self.busyDlg = wx.BusyInfo(msg)
        while not os.path.exists(self.schemaFile):
            time.sleep(0.5)
        self.busyDlg = None

def getNewSchema(self, Version):
    schemaType = "transitional"
    self.schemaFile = Version + "-" + schemaType + ".rng"
    command = '%s -m generateSchema -u %s -p %s -schema %s -schemaType %s -s shortname -destination .' % (self.params["Link"], self.params["Username"], self.params["Password"], Version, schemaType)
    if self.params["systemType"] == "Windows":
        command = command + " -WONoPause true"
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = Popen(command, startupinfo=startupinfo, shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
    else:
        p = Popen(shlex.split(command), shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)

不要使用管道,除非您供给/消耗相应的管道。如果您需要忽略输出,请查看它是否那么简单!删除所有管道命令使其正常工作。谢谢J.F.塞巴斯蒂安。