部署win2012R2 IIS8在post时提示[WinError 6] 句柄无效

部署后,可以正常运行index的表单页面,在提交后报错,请教这是什么问题,如何解决,感谢! OSError at /

[WinError 6] 句柄无效。

Request Method: POST Request URL: http://192.168.xx.xx:8081/ Django Version: 3.0 Exception Type: OSError Exception Value:

[WinError 6] 句柄无效。

Exception Location: c:\python38\lib\subprocess.py in _get_handles, line 1178 Python Executable: c:\python38\python.exe Python Version: 3.8.0 Python Path:

['.', 'C:\inetpub\xxxx\xxxx', 'c:\python38\python38.zip', 'c:\python38\DLLs', 'c:\python38\lib', 'c:\python38', 'c:\python38\lib\site-packages']

评论 2

  • 贴个Traceback Traceback Switch to copy-and-paste view

    c:\python38\lib\site-packages\django\core\handlers\exception.py in inner
    
                    response = get_response(request)
    
         …
    ▼ Local vars
    Variable    Value
    exc
    
    OSError(9, '句柄无效。', None, 6, None)
    
    get_response
    
    <bound method BaseHandler._get_response of <django.core.handlers.wsgi.WSGIHandler object at 0x000000B22A9C7760>>
    
    request
    
    <WSGIRequest: POST '/'>
    
    c:\python38\lib\site-packages\django\core\handlers\base.py in _get_response
    
                        response = self.process_exception_by_middleware(e, request)
    
         …
    ▼ Local vars
    Variable    Value
    callback
    
    <function index at 0x000000B22B0F19D0>
    
    callback_args
    
    ()
    
    callback_kwargs
    
    {}
    
    middleware_method
    
    <bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x000000B22AEAF1C0>>
    
    request
    
    <WSGIRequest: POST '/'>
    
    resolver
    
    <URLResolver 'xxxx.urls' (None:None) '^/'>
    
    resolver_match
    
    ResolverMatch(func=tools.views.index, args=(), kwargs={}, url_name=home, app_names=[], namespaces=[], route=^$)
    
    response
    
    None
    
    self
    
    <django.core.handlers.wsgi.WSGIHandler object at 0x000000B22A9C7760>
    
    wrapped_callback
    
    <function index at 0x000000B22B0F19D0>
    
    c:\python38\lib\site-packages\django\core\handlers\base.py in _get_response
    
                        response = wrapped_callback(request, *callback_args, **callback_kwargs)
    
         …
    ▼ Local vars
    Variable    Value
    callback
    
    <function index at 0x000000B22B0F19D0>
    
    callback_args
    
    ()
    
    callback_kwargs
    
    {}
    
    middleware_method
    
    <bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x000000B22AEAF1C0>>
    
    request
    
    <WSGIRequest: POST '/'>
    
    resolver
    
    <URLResolver 'xxxx.urls' (None:None) '^/'>
    
    resolver_match
    
    ResolverMatch(func=tools.views.index, args=(), kwargs={}, url_name=home, app_names=[], namespaces=[], route=^$)
    
    response
    
    None
    
    self
    
    <django.core.handlers.wsgi.WSGIHandler object at 0x000000B22A9C7760>
    
    wrapped_callback
    
    <function index at 0x000000B22B0F19D0>
    
    .\tools\views.py in index
    
                    p=subprocess.Popen(args, stdout=subprocess.PIPE)
    
         …
    ▼ Local vars
    Variable    Value
    acc
    
    'xxxx'
    
    args
    
    ['C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe',
     '-ExecutionPolicy',
     'RemoteSigned',
     'c:\\inetpub\\xxxx\\tools\\xxxx_deviceActive.ps1',
     'xxxx',
     '123456']
    
    form
    
    <AddForm bound=True, valid=True, fields=(account;token)>
    
    request
    
    <WSGIRequest: POST '/'>
    
    res
    
    {}
    
    tk
    
    '123456'
    
    c:\python38\lib\subprocess.py in __init__
    
                 errread, errwrite) = self._get_handles(stdin, stdout, stderr)
    
         …
    ▼ Local vars
    Variable    Value
    args
    
    ['C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe',
     '-ExecutionPolicy',
     'RemoteSigned',
     'c:\\inetpub\\xxxx\\tools\\xxxx_deviceActive.ps1',
     'xxxx',
     '123456']
    
    bufsize
    
    -1
    
    close_fds
    
    True
    
    creationflags
    
    0
    
    cwd
    
    None
    
    encoding
    
    None
    
    env
    
    None
    
    errors
    
    None
    
    executable
    
    None
    
    pass_fds
    
    ()
    
    preexec_fn
    
    None
    
    restore_signals
    
    True
    
    self
    
    <subprocess.Popen object at 0x000000B22B1700D0>
    
    shell
    
    False
    
    start_new_session
    
    False
    
    startupinfo
    
    None
    
    stderr
    
    None
    
    stdin
    
    None
    
    stdout
    
    -1
    
    text
    
    None
    
    universal_newlines
    
    None
    
    c:\python38\lib\subprocess.py in _get_handles
    
                        errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE)
    
         …
    ▼ Local vars
    Variable    Value
    c2pread
    
    Handle(428)
    
    c2pwrite
    
    Handle(444)
    
    errread
    
    -1
    
    errwrite
    
    -1
    
    p2cread
    
    Handle(440)
    
    p2cwrite
    
    -1
    
    self
    
    <subprocess.Popen object at 0x000000B22B1700D0>
    
    stderr
    
    None
    
    stdin
    
    None
    
    stdout
    
    -1