Delay load some particularly heavy stdlib modules that are not often needed
This commit is contained in:
parent
86686bfac7
commit
de1a2f7682
@ -6,7 +6,6 @@ import atexit
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
from functools import partial
|
||||
from gettext import gettext as _
|
||||
from weakref import WeakValueDictionary
|
||||
@ -43,6 +42,7 @@ def initialize_renderer():
|
||||
|
||||
|
||||
def listen_on(spec):
|
||||
import socket
|
||||
family, address, socket_path = parse_address_spec(spec)
|
||||
s = socket.socket(family)
|
||||
atexit.register(remove_socket_file, s, socket_path)
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import deque
|
||||
|
||||
@ -349,6 +348,7 @@ def print_help_for_seq(seq, usage, message, appname):
|
||||
|
||||
text = '\n'.join(blocks) + '\n\n' + version()
|
||||
if print_help_for_seq.allow_pager and sys.stdout.isatty():
|
||||
import subprocess
|
||||
p = subprocess.Popen(['less', '-isRXF'], stdin=subprocess.PIPE)
|
||||
p.communicate(text.encode('utf-8'))
|
||||
raise SystemExit(p.wait())
|
||||
@ -577,6 +577,7 @@ def create_opts(args, debug_config=False):
|
||||
print(version(add_rev=True))
|
||||
print(' '.join(os.uname()))
|
||||
if is_macos:
|
||||
import subprocess
|
||||
print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip())
|
||||
else:
|
||||
print('Running under:', green('Wayland' if is_wayland else 'X11'))
|
||||
|
||||
@ -7,7 +7,6 @@ import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from collections import namedtuple
|
||||
from contextlib import contextmanager
|
||||
|
||||
@ -449,6 +448,7 @@ def build_ansi_color_table(opts=defaults):
|
||||
|
||||
|
||||
def atomic_save(data, path):
|
||||
import tempfile
|
||||
fd, p = tempfile.mkstemp(dir=os.path.dirname(path), suffix='.tmp')
|
||||
try:
|
||||
with os.fdopen(fd, 'wb') as f:
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
import json
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
from functools import partial
|
||||
@ -41,6 +40,7 @@ will only work if this process is run within an existing kitty window.
|
||||
|
||||
|
||||
def do_io(to, send, no_response):
|
||||
import socket
|
||||
send = ('@kitty-cmd' + json.dumps(send)).encode('ascii')
|
||||
send = b'\x1bP' + send + b'\x1b\\'
|
||||
if to:
|
||||
|
||||
@ -8,11 +8,8 @@ import fcntl
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
from time import monotonic
|
||||
|
||||
@ -121,6 +118,7 @@ def command_for_open(program='default'):
|
||||
|
||||
|
||||
def open_cmd(cmd, arg=None, cwd=None):
|
||||
import subprocess
|
||||
if arg is not None:
|
||||
cmd = list(cmd)
|
||||
cmd.append(arg)
|
||||
@ -201,6 +199,8 @@ def remove_socket_file(s, path=None):
|
||||
|
||||
|
||||
def single_instance_unix(name):
|
||||
import socket
|
||||
import tempfile
|
||||
home = os.path.expanduser('~')
|
||||
candidates = [tempfile.gettempdir(), home]
|
||||
if is_macos:
|
||||
@ -239,6 +239,7 @@ def single_instance_unix(name):
|
||||
|
||||
|
||||
def single_instance(group_id=None):
|
||||
import socket
|
||||
name = '{}-ipc-{}'.format(appname, os.geteuid())
|
||||
if group_id:
|
||||
name += '-{}'.format(group_id)
|
||||
@ -264,6 +265,7 @@ def single_instance(group_id=None):
|
||||
|
||||
|
||||
def parse_address_spec(spec):
|
||||
import socket
|
||||
protocol, rest = spec.split(':', 1)
|
||||
socket_path = None
|
||||
if protocol == 'unix':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user