“ImportError: No module named _ssl” with dev_appserver.py from Google App Engine

后端 未结 7 1933
误落风尘
误落风尘 2020-11-27 13:55

Background

\"In the Python runtime, we\'ve added support for the Python SSL Library, so you can now open secure connections to remote servic

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 14:26

    I had to use a slightly different approach to get this working in CircleCI (unsure what peculiarity about their venv config caused this):

    appengine_config.py

    import os
    
    if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
        import imp
        import os.path
        import inspect
        from google.appengine.tools.devappserver2.python import sandbox
    
        sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
        # Use the system socket.
    
        real_os_src_path = os.path.realpath(inspect.getsourcefile(os))
        psocket = os.path.join(os.path.dirname(real_os_src_path), 'socket.py')
        imp.load_source('socket', psocket)
    

提交回复
热议问题