|
43 | 43 | import builtins
|
44 | 44 | import errno
|
45 | 45 | import io
|
| 46 | +import locale |
46 | 47 | import os
|
47 | 48 | import time
|
| 49 | +import signal |
48 | 50 | import sys
|
49 | 51 | import threading
|
50 | 52 | import warnings
|
@@ -142,8 +144,6 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
|
142 | 144 |
|
143 | 145 | def __str__(self):
|
144 | 146 | if self.returncode and self.returncode < 0:
|
145 |
| - # Lazy import to improve module import time |
146 |
| - import signal |
147 | 147 | try:
|
148 | 148 | return "Command '%s' died with %r." % (
|
149 | 149 | self.cmd, signal.Signals(-self.returncode))
|
@@ -381,8 +381,6 @@ def _text_encoding():
|
381 | 381 | if sys.flags.utf8_mode:
|
382 | 382 | return "utf-8"
|
383 | 383 | else:
|
384 |
| - # Lazy import to improve module import time |
385 |
| - import locale |
386 | 384 | return locale.getencoding()
|
387 | 385 |
|
388 | 386 |
|
@@ -1667,9 +1665,6 @@ def send_signal(self, sig):
|
1667 | 1665 | # Don't signal a process that we know has already died.
|
1668 | 1666 | if self.returncode is not None:
|
1669 | 1667 | return
|
1670 |
| - |
1671 |
| - # Lazy import to improve module import time |
1672 |
| - import signal |
1673 | 1668 | if sig == signal.SIGTERM:
|
1674 | 1669 | self.terminate()
|
1675 | 1670 | elif sig == signal.CTRL_C_EVENT:
|
@@ -1771,9 +1766,6 @@ def _posix_spawn(self, args, executable, env, restore_signals, close_fds,
|
1771 | 1766 | """Execute program using os.posix_spawn()."""
|
1772 | 1767 | kwargs = {}
|
1773 | 1768 | if restore_signals:
|
1774 |
| - # Lazy import to improve module import time |
1775 |
| - import signal |
1776 |
| - |
1777 | 1769 | # See _Py_RestoreSignals() in Python/pylifecycle.c
|
1778 | 1770 | sigset = []
|
1779 | 1771 | for signame in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
|
@@ -2223,13 +2215,9 @@ def send_signal(self, sig):
|
2223 | 2215 | def terminate(self):
|
2224 | 2216 | """Terminate the process with SIGTERM
|
2225 | 2217 | """
|
2226 |
| - # Lazy import to improve module import time |
2227 |
| - import signal |
2228 | 2218 | self.send_signal(signal.SIGTERM)
|
2229 | 2219 |
|
2230 | 2220 | def kill(self):
|
2231 | 2221 | """Kill the process with SIGKILL
|
2232 | 2222 | """
|
2233 |
| - # Lazy import to improve module import time |
2234 |
| - import signal |
2235 | 2223 | self.send_signal(signal.SIGKILL)
|
0 commit comments