运行High Sierra时,我在osx上遇到了麻烦。
问题在于,在以下代码中,对request.get的调用没有任何作用。它根本不会使其脱离呼叫,也不会引发错误。 get调用之后的print方法不会执行,但是该应用程序不会崩溃,它像没有任何反应一样继续进入主循环。
同样的代码在Linux上运行良好。我正在研究如何在Windows上尝试它,并希望另外安装osx。
我在这里完全不知所措。它甚至不会引发错误的事实对我来说很奇怪。
variable "managed_policies" {
default = ["arn:aws:iam::aws:policy/AWSCodeCommitFullAccess",
"arn:aws:iam::aws:policy/AWSCodeBuildAdminAccess",
"arn:aws:iam::aws:policy/AWSCodeDeployFullAccess",
"arn:aws:iam::aws:policy/AWSCodePipelineFullAccess",
]
}
resource "aws_iam_role_policy_attachment" "tc-role-policy-attach" {
count = "${length(var.managed_policies)}"
policy_arn = "${element(var.managed_policies, count.index)}"
role = "${aws_iam_role.toolchain-role.name}"
}
此外,如果我跟随调试器进行操作,它会在此时进入请求库中的黑洞。
import tkinter as tk
from tkinter import ttk
import multiprocessing
import time
import requests
class SplashScreen(tk.Toplevel):
def __init__(self, root):
super(SplashScreen, self).__init__(root)
self.width = 800
self.height = 400
self.geometry('{Width}x{Height}'.format(Width=self.width, Height=self.height))
self.overrideredirect(True)
self.label = ttk.Label(self, text='My Splash', anchor='center')
self.label.grid(column=0, row=2)
def destroy_splash_screen(self):
self.destroy()
print('destroyed splash')
class App(tk.Tk):
def __init__(self):
super(App, self).__init__()
self.splash = SplashScreen(self)
self.withdraw()
process_startup = multiprocessing.Process(
target=self.startup_process,
args=("stuff",)
)
process_startup.start()
self.splash.update()
while process_startup.is_alive():
time.sleep(0.1)
self.title("MyApp")
self.mainloop()
def mainloop(self, n=0):
first_loop = True
while True:
self.update_idletasks()
self.update()
if first_loop:
self.remove_splash_screen()
first_loop = False
def startup_process(self, things):
init_client()
def remove_splash_screen(self):
self.splash.destroy_splash_screen()
del self.splash
self.deiconify()
def init_client():
requests.get("http://httpbin.org/ip")
s = 'strfff'
print(s)
if __name__ == '__main__':
app = App()
此代码位于request / utils.py
中从何处开始的任何想法。就像我说的那样,我现在完全处于茫然之中。
答案 0 :(得分:1)
在MacOS上,requests
似乎有点毛病。尝试通过将trust_env
设置为False
来禁用代理:
session = requests.Session()
session.trust_env = False # No proxy settings from the OS
r = session.get(url)