Kaydet (Commit) 04842a84 authored tarafından Florent Xicluna's avatar Florent Xicluna

Remove unused or redundant imports in concurrent.futures and multiprocessing.

üst f8240d65
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
__author__ = 'Brian Quinlan (brian@sweetapp.com)' __author__ = 'Brian Quinlan (brian@sweetapp.com)'
import collections import collections
import functools
import logging import logging
import threading import threading
import time import time
......
...@@ -221,7 +221,7 @@ def _queue_management_worker(executor_reference, ...@@ -221,7 +221,7 @@ def _queue_management_worker(executor_reference,
assert sentinels assert sentinels
try: try:
result_item = result_queue.get(sentinels=sentinels) result_item = result_queue.get(sentinels=sentinels)
except SentinelReady as e: except SentinelReady:
# Mark the process pool broken so that submits fail right now. # Mark the process pool broken so that submits fail right now.
executor = executor_reference() executor = executor_reference()
if executor is not None: if executor is not None:
...@@ -291,7 +291,6 @@ def _check_system_limits(): ...@@ -291,7 +291,6 @@ def _check_system_limits():
raise NotImplementedError(_system_limited) raise NotImplementedError(_system_limited)
_system_limits_checked = True _system_limits_checked = True
try: try:
import os
nsems_max = os.sysconf("SC_SEM_NSEMS_MAX") nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
except (AttributeError, ValueError): except (AttributeError, ValueError):
# sysconf not available or setting not available # sysconf not available or setting not available
......
...@@ -74,7 +74,7 @@ def _worker(executor_reference, work_queue): ...@@ -74,7 +74,7 @@ def _worker(executor_reference, work_queue):
work_queue.put(None) work_queue.put(None)
return return
del executor del executor
except BaseException as e: except BaseException:
_base.LOGGER.critical('Exception in worker', exc_info=True) _base.LOGGER.critical('Exception in worker', exc_info=True)
class ThreadPoolExecutor(_base.Executor): class ThreadPoolExecutor(_base.Executor):
......
...@@ -46,9 +46,7 @@ import threading ...@@ -46,9 +46,7 @@ import threading
import sys import sys
import weakref import weakref
import array import array
import itertools
from multiprocessing import TimeoutError, cpu_count
from multiprocessing.dummy.connection import Pipe from multiprocessing.dummy.connection import Pipe
from threading import Lock, RLock, Semaphore, BoundedSemaphore from threading import Lock, RLock, Semaphore, BoundedSemaphore
from threading import Event, Condition from threading import Event, Condition
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
import os import os
import sys import sys
import signal import signal
import select
from multiprocessing import util, process from multiprocessing import util, process
...@@ -101,7 +100,6 @@ else: ...@@ -101,7 +100,6 @@ else:
# #
if sys.platform != 'win32': if sys.platform != 'win32':
import time
import select import select
exit = os._exit exit = os._exit
...@@ -170,7 +168,7 @@ if sys.platform != 'win32': ...@@ -170,7 +168,7 @@ if sys.platform != 'win32':
if self.returncode is None: if self.returncode is None:
try: try:
os.kill(self.pid, signal.SIGTERM) os.kill(self.pid, signal.SIGTERM)
except OSError as e: except OSError:
if self.wait(timeout=0.1) is None: if self.wait(timeout=0.1) is None:
raise raise
...@@ -186,11 +184,9 @@ else: ...@@ -186,11 +184,9 @@ else:
import _thread import _thread
import msvcrt import msvcrt
import _subprocess import _subprocess
import time
from pickle import dump, load, HIGHEST_PROTOCOL from pickle import load, HIGHEST_PROTOCOL
from _multiprocessing import win32 from _multiprocessing import win32
from .util import Finalize
def dump(obj, file, protocol=None): def dump(obj, file, protocol=None):
ForkingPickler(file, protocol).dump(obj) ForkingPickler(file, protocol).dump(obj)
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
import bisect import bisect
import mmap import mmap
import tempfile
import os import os
import sys import sys
import threading import threading
......
...@@ -39,19 +39,15 @@ __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ] ...@@ -39,19 +39,15 @@ __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ]
# Imports # Imports
# #
import os
import sys import sys
import weakref
import threading import threading
import array import array
import queue import queue
from traceback import format_exc from traceback import format_exc
from pickle import PicklingError
from multiprocessing import Process, current_process, active_children, Pool, util, connection from multiprocessing import Process, current_process, active_children, Pool, util, connection
from multiprocessing.process import AuthenticationString from multiprocessing.process import AuthenticationString
from multiprocessing.forking import exit, Popen, assert_spawning, ForkingPickler from multiprocessing.forking import exit, Popen, ForkingPickler
from multiprocessing.util import Finalize, info
# #
# Register some things for pickling # Register some things for pickling
......
...@@ -39,7 +39,6 @@ import os ...@@ -39,7 +39,6 @@ import os
import threading import threading
import collections import collections
import time import time
import atexit
import weakref import weakref
import errno import errno
......
...@@ -41,7 +41,6 @@ import socket ...@@ -41,7 +41,6 @@ import socket
import threading import threading
import struct import struct
import _multiprocessing
from multiprocessing import current_process from multiprocessing import current_process
from multiprocessing.forking import Popen, duplicate, close, ForkingPickler from multiprocessing.forking import Popen, duplicate, close, ForkingPickler
from multiprocessing.util import register_after_fork, debug, sub_debug from multiprocessing.util import register_after_fork, debug, sub_debug
...@@ -61,7 +60,6 @@ if not(sys.platform == 'win32' or (hasattr(socket, 'CMSG_LEN') and ...@@ -61,7 +60,6 @@ if not(sys.platform == 'win32' or (hasattr(socket, 'CMSG_LEN') and
# #
if sys.platform == 'win32': if sys.platform == 'win32':
import _subprocess
from _multiprocessing import win32 from _multiprocessing import win32
def send_handle(conn, handle, destination_pid): def send_handle(conn, handle, destination_pid):
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
# SUCH DAMAGE. # SUCH DAMAGE.
# #
import sys
import ctypes import ctypes
import weakref import weakref
......
...@@ -37,14 +37,11 @@ __all__ = [ ...@@ -37,14 +37,11 @@ __all__ = [
] ]
import threading import threading
import os
import sys import sys
from time import time as _time, sleep as _sleep
import _multiprocessing import _multiprocessing
from multiprocessing.process import current_process from multiprocessing.process import current_process
from multiprocessing.util import Finalize, register_after_fork, debug from multiprocessing.util import register_after_fork, debug
from multiprocessing.forking import assert_spawning, Popen from multiprocessing.forking import assert_spawning, Popen
# Try to import the mp.synchronize module cleanly, if it fails # Try to import the mp.synchronize module cleanly, if it fails
......
...@@ -36,7 +36,6 @@ import functools ...@@ -36,7 +36,6 @@ import functools
import itertools import itertools
import weakref import weakref
import atexit import atexit
import select
import threading # we want threading to install it's import threading # we want threading to install it's
# cleanup function before multiprocessing does # cleanup function before multiprocessing does
...@@ -86,7 +85,7 @@ def get_logger(): ...@@ -86,7 +85,7 @@ def get_logger():
Returns logger used by multiprocessing Returns logger used by multiprocessing
''' '''
global _logger global _logger
import logging, atexit import logging
logging._acquireLock() logging._acquireLock()
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment