У меня проблемы с osx, особенно с этим, при запуске High Sierra.
Проблема заключается в том, что в следующем коде вызов request.get ничего не делает.Это не делает его из вызова вообще, а также не вызывает ошибку.Метод print после вызова get не выполняется, но приложение не падает, оно просто переходит к основному циклу, как будто ничего не произошло.
Этот же код прекрасно работает в linux.Я работаю, как я могу попробовать это на Windows, а также, надеюсь, еще одна установка OSX.
Я в полной растерянности.Тот факт, что он даже не вызывает ошибку, странен для меня.
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()
Кроме того, если я выполняю его с помощью отладчика, он попадает в черную дыру в этой точке библиотеки запросов.
def should_bypass_proxies(url, no_proxy):
"""
Returns whether we should bypass proxies or not.
:rtype: bool
"""
# Prioritize lowercase environment variables over uppercase
# to keep a consistent behaviour with other http projects (curl, wget).
get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())
# First check whether no_proxy is defined. If it is, check that the URL
# we're getting isn't in the no_proxy list.
no_proxy_arg = no_proxy
if no_proxy is None:
no_proxy = get_proxy('no_proxy')
parsed = urlparse(url)
if parsed.hostname is None:
# URLs don't always have hostnames, e.g. file:/// urls.
return True
if no_proxy:
# We need to check whether we match here. We need to see if we match
# the end of the hostname, both with and without the port.
no_proxy = (
host for host in no_proxy.replace(' ', '').split(',') if host
)
if is_ipv4_address(parsed.hostname):
for proxy_ip in no_proxy:
if is_valid_cidr(proxy_ip):
if address_in_network(parsed.hostname, proxy_ip):
return True
elif parsed.hostname == proxy_ip:
# If no_proxy ip was defined in plain IP notation instead of cidr notation &
# matches the IP of the index
return True
else:
host_with_port = parsed.hostname
if parsed.port:
host_with_port += ':{}'.format(parsed.port)
for host in no_proxy:
if parsed.hostname.endswith(host) or host_with_port.endswith(host):
# The URL does match something in no_proxy, so we don't want
# to apply the proxies on this URL.
return True
with set_environ('no_proxy', no_proxy_arg):
# parsed.hostname can be `None` in cases such as a file URI.
try:
# It executes this method and returns when stepped through but from here it just ends. doesn't go anywhere from this point
bypass = proxy_bypass(parsed.hostname)
except (TypeError, socket.gaierror):
bypass = False
if bypass:
return True
return False
Этот код находится в запросах / utils.py
Любые идеи о том, с чего начать.Как я уже сказал, сейчас я в полной растерянности.