portage.dbapi._MergeProcess module

class portage.dbapi._MergeProcess.MergeProcess(**kwargs)

Bases: portage.util._async.ForkProcess.ForkProcess

Merge packages in a subprocess, so the Scheduler can run in the main thread while files are moved or copied asynchronously.

_CGROUP_CLEANUP_RETRY_MAX = 8
_async_wait()

Subclasses call this method in order to invoke exit listeners when self.returncode is set. Subclasses may override this method in order to perform cleanup. The default implementation for this method simply calls self.wait(), which will immediately raise an InvalidStateError if the event loop is running and self.returncode is None.

_async_waitpid()

Wait for exit status of self.pid asynchronously, and then set the returncode, and finally notify exit listeners via the _async_wait method. Subclasses may override this method in order to implement an alternative means to retrieve pid exit status, or as a means to delay action until some pending task(s) have completed (such as reading data that the subprocess is supposed to have written to a pipe).

_async_waitpid_cb(pid, returncode)
_bootstrap(fd_pipes)
_buf
_bufsize = 4096
_can_log(slave_fd)
_cancel()

Subclasses should implement this, as a template method to be called by AsynchronousTask.cancel().

_cancel_timeout = 1
_cancelled_returncode = -2
_cgroup_cleanup()
_counter
_dummy_pipe_fd
_elog(elog_funcname, lines)
_elog_keys
_elog_output_handler()
_elog_reader_fd
_exit_listener_cb(listener)
_exit_listener_handles
_exit_listeners
_files
_lock_vdb()

Lock the vdb if FEATURES=parallel-install is NOT enabled, otherwise do nothing. This is implemented with vardbapi.lock(), which supports reentrance by the subprocess that we spawn.

_locked_vdb
async _main(build_logger, pipe_logger, loop=None)
_main_cancel(build_logger, pipe_logger)
_main_exit(main_task)
_main_task
_main_task_cancel
_mtime_handler()
_mtime_reader
_orphan_process_warn()
_pipe(fd_pipes)
Parameters

fd_pipes (dict) – pipes from which to copy terminal size if desired.

_poll()
_proc
async _proc_join(proc, loop=None)
_proc_join_done(proc, future)

Extend _proc_join_done to react to RETURNCODE_POSTINST_FAILURE.

_proc_join_interval = 0.1
_proc_join_task
_read_array(f)

NOTE: array.fromfile() is used here only for testing purposes, because it has bugs in all known versions of Python (including Python 2.7 and Python 3.2). See PipeReaderArrayTestCase.

A benchmark that copies bytes from /dev/zero to /dev/null shows that arrays give a 15% performance improvement for Python 2.7.14. However, arrays significantly decrease performance for Python 3.

_read_buf(fd)

Read self._bufsize into a string of bytes, handling EAGAIN and EIO. This will only call os.read() once, so the caller should call this method in a loop until either None or an empty string of bytes is returned. An empty string of bytes indicates EOF. None indicates EAGAIN.

NOTE: os.read() will be called regardless of the event flags,

since otherwise data may be lost (see bug #531724).

Parameters

fd (int) – file descriptor (non-blocking mode required)

Return type

bytes or None

Returns

A string of bytes, or None

_registered
_run()
_selinux_type
_spawn(args, fd_pipes, **kwargs)

Extend the superclass _spawn method to perform some pre-fork and post-fork actions.

_spawn_kwarg_names = ('env', 'opt_name', 'fd_pipes', 'uid', 'gid', 'groups', 'umask', 'logfile', 'path_lookup', 'pre_exec', 'close_fds', 'cgroup', 'unshare_ipc', 'unshare_mount', 'unshare_pid', 'unshare_net')
_start()
_start_hook()
_start_listeners
_unlock_vdb()

Unlock the vdb if we hold a lock, otherwise do nothing.

_unregister()

Unregister from the scheduler and close open files.

_wait_hook()

Call this method after the task completes, just before returning the returncode from wait() or poll(). This hook is used to trigger exit listeners when the returncode first becomes available.

_wait_loop(timeout=None)
_waitpid_id
_was_cancelled()

If cancelled, set returncode if necessary and return True. Otherwise, return False.

addExitListener(f)

The function will be called with one argument, a reference to self.

addStartListener(f)

The function will be called with one argument, a reference to self.

args
async_wait()

Wait for returncode asynchronously. Notification is available via the add_done_callback method of the returned Future instance.

Returns

Future, result is self.returncode

background
blockers
cancel()

Cancel the task, but do not wait for exit status. If asynchronous exit notification is desired, then use addExitListener to add a listener before calling this method. NOTE: Synchronous waiting for status is not supported, since it would be vulnerable to hitting the recursion limit when a large number of tasks need to be terminated simultaneously, like in bug #402335.

cancelled
cgroup
close_fds
copy()

Create a new instance and copy all attributes defined from __slots__ (including those from inherited classes).

env
fd_pipes
gid
groups
infloc
isAlive()
log_filter_file
logfile
mycat
mydbapi
myebuild
mypkg
opt_name
path_lookup
pid
pkgloc
poll()
postinst_failure
pre_exec
prev_mtimes
removeExitListener(f)
removeStartListener(f)
returncode
scheduler
settings
start()

Start an asynchronous task and then return as soon as possible.

treetype
uid
umask
unmerge
unshare_ipc
unshare_mount
unshare_net
unshare_pid
vartree
wait()

Wait for the returncode attribute to become ready, and return it. If the returncode is not ready and the event loop is already running, then the async_wait() method should be used instead of wait(), because wait() will raise asyncio.InvalidStateError in this case.

Return type

int

Returns

the value of self.returncode