我正在使用请求库在python 3.3中构建一个应用程序.当我尝试获取具有SSL连接的URL时,我想使用verify = true验证它.这在运行我的python脚本时非常有效.
当我冻结相同的脚本时,它会崩溃.它错过了一些东西,我真的无法弄清楚如何将它集成到我的冻结应用程序中.
我收到以下错误(这也会触发其他错误,但我不在这里发布):
Traceback (most recent call last):
File "C:\Python33-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 422, in urlopen
body=body, headers=headers)
File "C:\Python33-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 274, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Python33-32\lib\http\client.py", line 1049, in request
self._send_request(method, url, body, headers)
File "C:\Python33-32\lib\http\client.py", line 1087, in _send_request
self.endheaders(body)
File "C:\Python33-32\lib\http\client.py", line 1045, in endheaders
self._send_output(message_body)
File "C:\Python33-32\lib\http\client.py", line 890, in _send_output
self.send(msg)
File "C:\Python33-32\lib\http\client.py", line 828, in send
self.connect()
File "C:\Python33-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 105, in connect
ssl_version=self.ssl_version)
File "C:\Python33-32\lib\site-packages\requests\packages\urllib3\util.py", line 281, in ssl_wrap_socket
context.load_verify_locations(ca_certs) …Run Code Online (Sandbox Code Playgroud) 我正在为这个问题苦苦挣扎一段时间。我正在构建一个使用主循环的小脚本。这是一个需要用户注意的过程。用户对这些步骤做出响应,然后使用某些功能会发生一些魔术
除此之外,我想产生另一个进程,该进程监视计算机系统中的某些特定事件,例如按指定键。如果发生这些事件,则它将启动与用户提供正确值时相同的功能。
因此,我需要进行两个过程:-主循环(允许用户交互)-后台“事件扫描器”,该事件搜索特定事件,然后对其做出反应。
我通过启动主循环和守护程序多处理进程来尝试此操作。问题是,当我启动后台进程时,它会启动,但是此后,我不会启动主循环。我将所有内容简化了一些,使其更加清晰:
import multiprocessing, sys, time
def main_loop():
while 1:
input = input('What kind of food do you like?')
print(input)
def test():
while 1:
time.sleep(1)
print('this should run in the background')
if __name__ == '__main__':
try:
print('hello!')
mProcess = multiprocessing.Process(target=test())
mProcess.daemon = True
mProcess.start()
#after starting main loop does not start while it prints out the test loop fine.
main_loop()
except:
sys.exit(0)
Run Code Online (Sandbox Code Playgroud)