當前位置: 首頁>>代碼示例>>Python>>正文


Python multiprocessing.reduction方法代碼示例

本文整理匯總了Python中multiprocessing.reduction方法的典型用法代碼示例。如果您正苦於以下問題:Python multiprocessing.reduction方法的具體用法?Python multiprocessing.reduction怎麽用?Python multiprocessing.reduction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在multiprocessing的用法示例。


在下文中一共展示了multiprocessing.reduction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _winapi_childhandle_after_createprocess_child

# 需要導入模塊: import multiprocessing [as 別名]
# 或者: from multiprocessing import reduction [as 別名]
def _winapi_childhandle_after_createprocess_child(self):
        """Called on Windows in the child process after the CreateProcess()
        system call. This is required for making the handle usable in the child.
        """

        if WINAPI_HANDLE_TRANSFER_STEAL:
            # In this case the handle has not been inherited by the child
            # process during CreateProcess(). Steal it from the parent.
            new_winapihandle = multiprocessing.reduction.steal_handle(
                self._parent_pid, self._parent_winapihandle)
            del self._parent_winapihandle
            del self._parent_pid
            # Restore C file descriptor with (read/write)only flag.
            self._fd = msvcrt.open_osfhandle(new_winapihandle, self._fd_flag)
            return

        # In this case the handle has been inherited by the child process during
        # the CreateProcess() system call. Get C file descriptor from Windows
        # file handle.
        self._fd = msvcrt.open_osfhandle(
            self._inheritable_winapihandle, self._fd_flag)

        del self._inheritable_winapihandle 
開發者ID:jgehrcke,項目名稱:gipc,代碼行數:25,代碼來源:gipc.py

示例2: rebuild_ndarray

# 需要導入模塊: import multiprocessing [as 別名]
# 或者: from multiprocessing import reduction [as 別名]
def rebuild_ndarray(pid, fd, shape, dtype):
        """Rebuild ndarray from pickled shared memory"""
        # pylint: disable=no-value-for-parameter
        if sys.version_info[0] == 2:
            fd = multiprocessing.reduction.rebuild_handle(fd)
        else:
            fd = fd.detach()
        return nd.NDArray(nd.ndarray._new_from_shared_mem(pid, fd, shape, dtype)) 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:10,代碼來源:dataloader.py

示例3: reduce_ndarray

# 需要導入模塊: import multiprocessing [as 別名]
# 或者: from multiprocessing import reduction [as 別名]
def reduce_ndarray(data):
        """Reduce ndarray to shared memory handle"""
        # keep a local ref before duplicating fd
        data = data.as_in_context(context.Context('cpu_shared', 0))
        pid, fd, shape, dtype = data._to_shared_mem()
        if sys.version_info[0] == 2:
            fd = multiprocessing.reduction.reduce_handle(fd)
        else:
            fd = multiprocessing.reduction.DupFd(fd)
        return rebuild_ndarray, (pid, fd, shape, dtype) 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:12,代碼來源:dataloader.py

示例4: reduce_ndarray

# 需要導入模塊: import multiprocessing [as 別名]
# 或者: from multiprocessing import reduction [as 別名]
def reduce_ndarray(data):
        """Reduce ndarray to shared memory handle"""
        # keep a local ref before duplicating fd
        data = data.as_in_context(context.Context("cpu_shared", 0))
        pid, fd, shape, dtype = data._to_shared_mem()
        fd = multiprocessing.reduction.DupFd(fd)
        return rebuild_ndarray, (pid, fd, shape, dtype) 
開發者ID:awslabs,項目名稱:gluon-ts,代碼行數:9,代碼來源:parallelized_loader.py


注:本文中的multiprocessing.reduction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。