Back to index

python3.2  3.2.2
Functions | Variables
multiprocessing.reduction Namespace Reference

Functions

def send_handle
def recv_handle
def _reset
def _get_listener
def _serve
def reduce_handle
def rebuild_handle
def reduce_connection
def rebuild_connection
def fromfd
def reduce_socket
def rebuild_socket
def reduce_pipe_connection
def rebuild_pipe_connection

Variables

list __all__ = []
tuple _cache = set()

Function Documentation

Definition at line 102 of file reduction.py.

00102 
00103 def _get_listener():
00104     global _listener
00105 
00106     if _listener is None:
00107         _lock.acquire()
00108         try:
00109             if _listener is None:
00110                 debug('starting listener and thread for sending handles')
00111                 _listener = Listener(authkey=current_process().authkey)
00112                 t = threading.Thread(target=_serve)
00113                 t.daemon = True
00114                 t.start()
00115         finally:
00116             _lock.release()
00117 
00118     return _listener

Here is the caller graph for this function:

def multiprocessing.reduction._reset (   obj) [private]

Definition at line 91 of file reduction.py.

00091 
00092 def _reset(obj):
00093     global _lock, _listener, _cache
00094     for h in _cache:
00095         close(h)
00096     _cache.clear()
00097     _lock = threading.Lock()
00098     _listener = None
00099 
00100 _reset(None)
00101 register_after_fork(_reset, _reset)

Here is the call graph for this function:

Definition at line 119 of file reduction.py.

00119 
00120 def _serve():
00121     from .util import is_exiting, sub_warning
00122 
00123     while 1:
00124         try:
00125             conn = _listener.accept()
00126             handle_wanted, destination_pid = conn.recv()
00127             _cache.remove(handle_wanted)
00128             send_handle(conn, handle_wanted, destination_pid)
00129             close(handle_wanted)
00130             conn.close()
00131         except:
00132             if not is_exiting():
00133                 import traceback
00134                 sub_warning(
00135                     'thread for sharing handles raised exception :\n' +
00136                     '-'*79 + '\n' + traceback.format_exc() + '-'*79
00137                     )
00138 
00139 #
00140 # Functions to be used for pickling/unpickling objects with handles
00141 #

Here is the call graph for this function:

def multiprocessing.reduction.fromfd (   fd,
  family,
  type_,
  proto = 0 
)

Definition at line 181 of file reduction.py.

00181 
00182 def fromfd(fd, family, type_, proto=0):
00183     s = socket.fromfd(fd, family, type_, proto)
00184     if s.__class__ is not socket.socket:
00185         s = socket.socket(_sock=s)
00186     return s

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.reduction.rebuild_connection (   reduced_handle,
  readable,
  writable 
)

Definition at line 169 of file reduction.py.

00169 
00170 def rebuild_connection(reduced_handle, readable, writable):
00171     handle = rebuild_handle(reduced_handle)
00172     return _multiprocessing.Connection(
00173         handle, readable=readable, writable=writable
00174         )
00175 
00176 ForkingPickler.register(_multiprocessing.Connection, reduce_connection)
00177 
00178 #
00179 # Register `socket.socket` with `ForkingPickler`
00180 #

Here is the call graph for this function:

Definition at line 150 of file reduction.py.

00150 
00151 def rebuild_handle(pickled_data):
00152     address, handle, inherited = pickled_data
00153     if inherited:
00154         return handle
00155     sub_debug('rebuilding handle %d', handle)
00156     conn = Client(address, authkey=current_process().authkey)
00157     conn.send((handle, os.getpid()))
00158     new_handle = recv_handle(conn)
00159     conn.close()
00160     return new_handle
00161 
00162 #
00163 # Register `_multiprocessing.Connection` with `ForkingPickler`
00164 #

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.reduction.rebuild_pipe_connection (   reduced_handle,
  readable,
  writable 
)

Definition at line 209 of file reduction.py.

00209 
00210     def rebuild_pipe_connection(reduced_handle, readable, writable):
00211         handle = rebuild_handle(reduced_handle)
00212         return _multiprocessing.PipeConnection(
00213             handle, readable=readable, writable=writable
00214             )

Here is the call graph for this function:

def multiprocessing.reduction.rebuild_socket (   reduced_handle,
  family,
  type_,
  proto 
)

Definition at line 191 of file reduction.py.

00191 
00192 def rebuild_socket(reduced_handle, family, type_, proto):
00193     fd = rebuild_handle(reduced_handle)
00194     _sock = fromfd(fd, family, type_, proto)
00195     close(fd)
00196     return _sock
00197 
00198 ForkingPickler.register(socket.socket, reduce_socket)
00199 
00200 #
00201 # Register `_multiprocessing.PipeConnection` with `ForkingPickler`
00202 #

Here is the call graph for this function:

Definition at line 75 of file reduction.py.

00075 
00076     def recv_handle(conn):
00077         return conn.recv()
00078 
else:

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file reduction.py.

00165 
00166 def reduce_connection(conn):
00167     rh = reduce_handle(conn.fileno())
00168     return rebuild_connection, (rh, conn.readable, conn.writable)

Here is the call graph for this function:

Definition at line 142 of file reduction.py.

00142 
00143 def reduce_handle(handle):
00144     if Popen.thread_is_spawning():
00145         return (None, Popen.duplicate_for_child(handle), True)
00146     dup_handle = duplicate(handle)
00147     _cache.add(dup_handle)
00148     sub_debug('reducing handle %d', handle)
00149     return (_get_listener().address, dup_handle, False)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 205 of file reduction.py.

00205 
00206     def reduce_pipe_connection(conn):
00207         rh = reduce_handle(conn.fileno())
00208         return rebuild_pipe_connection, (rh, conn.readable, conn.writable)

Here is the call graph for this function:

Definition at line 187 of file reduction.py.

00187 
00188 def reduce_socket(s):
00189     reduced_handle = reduce_handle(s.fileno())
00190     return rebuild_socket, (reduced_handle, s.family, s.type, s.proto)

Here is the call graph for this function:

def multiprocessing.reduction.send_handle (   conn,
  handle,
  destination_pid 
)

Definition at line 65 of file reduction.py.

00065 
00066     def send_handle(conn, handle, destination_pid):
00067         process_handle = win32.OpenProcess(
00068             win32.PROCESS_ALL_ACCESS, False, destination_pid
00069             )
00070         try:
00071             new_handle = duplicate(handle, process_handle)
00072             conn.send(new_handle)
00073         finally:
00074             close(process_handle)

Here is the caller graph for this function:


Variable Documentation

Definition at line 36 of file reduction.py.

Definition at line 89 of file reduction.py.