How to use the joblib.externals.loky.backend.reduction._mk_inheritable function in joblib

To help you get started, we’ve selected a few joblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joblib / joblib / joblib / externals / loky / backend / resource_tracker.py View on Github external
def spawnv_passfds(path, args, passfds):
    passfds = sorted(passfds)
    if sys.platform != "win32":
        errpipe_read, errpipe_write = os.pipe()
        try:
            from .reduction import _mk_inheritable
            _pass = []
            for fd in passfds:
                _pass += [_mk_inheritable(fd)]
            from .fork_exec import fork_exec
            return fork_exec(args, _pass)
        finally:
            os.close(errpipe_read)
            os.close(errpipe_write)
    else:
        cmd = ' '.join('"%s"' % x for x in args)
        try:
            hp, ht, pid, tid = _winapi.CreateProcess(
                path, cmd, None, None, True, 0, None, None, None)
            _winapi.CloseHandle(ht)
        except BaseException:
            pass
        return pid
github joblib / joblib / joblib / externals / loky / backend / popen_loky_posix.py View on Github external
finally:
                set_spawning_popen(None)

            try:
                parent_r, child_w = os.pipe()
                child_r, parent_w = os.pipe()
                # for fd in self._fds:
                #     _mk_inheritable(fd)

                cmd_python = [sys.executable]
                cmd_python += ['-m', self.__module__]
                cmd_python += ['--process-name', str(process_obj.name)]
                cmd_python += ['--pipe',
                               str(reduction._mk_inheritable(child_r))]
                reduction._mk_inheritable(child_w)
                reduction._mk_inheritable(tracker_fd)
                self._fds.extend([child_r, child_w, tracker_fd])
                from .fork_exec import fork_exec
                pid = fork_exec(cmd_python, self._fds, env=process_obj.env)
                util.debug("launched python with pid {} and cmd:\n{}"
                           .format(pid, cmd_python))
                self.sentinel = parent_r

                method = 'getbuffer'
                if not hasattr(fp, method):
                    method = 'getvalue'
                with os.fdopen(parent_w, 'wb') as f:
                    f.write(getattr(fp, method)())
                self.pid = pid
            finally:
                if parent_r is not None:
github joblib / joblib / joblib / externals / loky / backend / popen_loky_posix.py View on Github external
def duplicate_for_child(self, fd):
                self._fds.append(fd)
                return reduction._mk_inheritable(fd)
github joblib / joblib / joblib / externals / loky / backend / popen_loky_posix.py View on Github external
reduction.dump(process_obj, fp)

            finally:
                set_spawning_popen(None)

            try:
                parent_r, child_w = os.pipe()
                child_r, parent_w = os.pipe()
                # for fd in self._fds:
                #     _mk_inheritable(fd)

                cmd_python = [sys.executable]
                cmd_python += ['-m', self.__module__]
                cmd_python += ['--process-name', str(process_obj.name)]
                cmd_python += ['--pipe',
                               str(reduction._mk_inheritable(child_r))]
                reduction._mk_inheritable(child_w)
                reduction._mk_inheritable(tracker_fd)
                self._fds.extend([child_r, child_w, tracker_fd])
                from .fork_exec import fork_exec
                pid = fork_exec(cmd_python, self._fds, env=process_obj.env)
                util.debug("launched python with pid {} and cmd:\n{}"
                           .format(pid, cmd_python))
                self.sentinel = parent_r

                method = 'getbuffer'
                if not hasattr(fp, method):
                    method = 'getvalue'
                with os.fdopen(parent_w, 'wb') as f:
                    f.write(getattr(fp, method)())
                self.pid = pid
            finally:
github joblib / joblib / joblib / externals / loky / backend / popen_loky_posix.py View on Github external
finally:
                set_spawning_popen(None)

            try:
                parent_r, child_w = os.pipe()
                child_r, parent_w = os.pipe()
                # for fd in self._fds:
                #     _mk_inheritable(fd)

                cmd_python = [sys.executable]
                cmd_python += ['-m', self.__module__]
                cmd_python += ['--process-name', str(process_obj.name)]
                cmd_python += ['--pipe',
                               str(reduction._mk_inheritable(child_r))]
                reduction._mk_inheritable(child_w)
                reduction._mk_inheritable(tracker_fd)
                self._fds.extend([child_r, child_w, tracker_fd])
                from .fork_exec import fork_exec
                pid = fork_exec(cmd_python, self._fds, env=process_obj.env)
                util.debug("launched python with pid {} and cmd:\n{}"
                           .format(pid, cmd_python))
                self.sentinel = parent_r

                method = 'getbuffer'
                if not hasattr(fp, method):
                    method = 'getvalue'
                with os.fdopen(parent_w, 'wb') as f:
                    f.write(getattr(fp, method)())
                self.pid = pid
            finally:
                if parent_r is not None:
                    util.Finalize(self, os.close, (parent_r,))