Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.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
Php IIS启动的Python进程在一段时间后停止运行_Php_Python_Iis 8_Windows Server 2016 - Fatal编程技术网

Php IIS启动的Python进程在一段时间后停止运行

Php IIS启动的Python进程在一段时间后停止运行,php,python,iis-8,windows-server-2016,Php,Python,Iis 8,Windows Server 2016,我编写了一个python脚本,从给定的网页收集链接。您可以在下面找到一个代码片段。(但我认为这不是编码问题) 当我在命令行中执行脚本(具有管理员权限)时,一切正常,但当我从PHP运行脚本时,它会在大约30分钟后停止运行,没有任何异常。对我来说,Windows Server 2016似乎在一段时间后终止了python进程(进程由IIS用户启动,但没有管理员权限) 你知道如何告诉Windows/IIS不要杀死python进程吗 这就是我从PHP调用脚本的方式: $command = 'C:\\Pyt

我编写了一个
python
脚本,从给定的网页收集链接。您可以在下面找到一个代码片段。(但我认为这不是编码问题)

当我在命令行中执行脚本(具有管理员权限)时,一切正常,但当我从
PHP
运行脚本时,它会在大约30分钟后停止运行,没有任何异常。对我来说,Windows Server 2016似乎在一段时间后终止了
python
进程(进程由IIS用户启动,但没有管理员权限)

你知道如何告诉Windows/IIS不要杀死
python
进程吗

这就是我从
PHP
调用脚本的方式:

$command = 'C:\\Python36\\python.exe C:\\Scripts\\myscript.py ';
pclose(popen("start /B ".$command, "w"));
我尝试了
python.exe
pythonw.exe
。脚本正常启动,但大约30分钟后停止

def getAllLinksOnCurrentPage():
elems = driver.find_elements_by_xpath("//a[@href]")
for elem in elems:
    f = elem.get_attribute("href")
    if testurl in f:
        if f not in linkcollector:
            linkcollector.append(f)


try:
    driver.get(testurl)

    for currentpage in linkcollector:
        driver.get(currentpage)
        getAllLinksOnCurrentPage()


    #Write all URLs to Logfile
    with open('C:\Scripts\Logfiles\\Logfile.txt', "a") as file:
        for currentpage in linkcollector:
            file.write("\n%s" %currentpage)

except Exception as e:
    #Catch Unknown Exception
    with open('C:\Scripts\Logfiles\\'+str(testrun)+'_Logfile.txt', "a") as file:
        file.write("\n Unknown Exception: " %str(e))
非常感谢您的每一个意见,谢谢

这可能与-脚本在终止前允许运行的最长时间(秒)有关


您可以通过编辑php.ini或调用自己找到的解决方案来更改此属性:


IIS->选择服务器->默认应用程序池->高级设置->将0设置为“空闲超时”和“常规时间间隔”

更新版本的PHP不支持最大执行时间即使将池设置为“始终运行”模式并将网站设置为“预加载”启用后,此选项也不起作用。大约5分钟后,如果没有请求,python进程将终止。您找到解决方案了吗?