portage.package.ebuild._spawn_nofetch module

class portage.package.ebuild._spawn_nofetch.SpawnNofetchWithoutBuilddir(**kwargs)

Bases: _emerge.CompositeTask.CompositeTask

This spawns pkg_nofetch if appropriate, while avoiding the need to lock a global build directory. The settings parameter is useful only if setcpv has already been called in order to cache metadata. It will be cloned internally, in order to prevent any changes from interfering with the calling code. If settings is None then a suitable config instance will be acquired from the given portdbapi instance. Do not use the settings parameter unless setcpv has been called on the given instance, since otherwise it’s possible to trigger issues like bug #408817 due to fragile assumptions involving the config state inside doebuild_environment().

A private PORTAGE_BUILDDIR will be created and cleaned up, in order to avoid any interference with any other processes. If PORTAGE_TMPDIR is writable, that will be used, otherwise the default directory for the tempfile module will be used.

We only call the pkg_nofetch phase if either RESTRICT=fetch is set or the package has explicitly overridden the default pkg_nofetch implementation. This allows specialized messages to be displayed for problematic packages even though they do not set RESTRICT=fetch (bug #336499).

This class does nothing if the PORTAGE_PARALLEL_FETCHONLY variable is set in the config instance.


Raises an AssertionError if the given task is not the same one as self._current_task. This can be useful for detecting bugs.


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.


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

_cancelled_returncode = -2

Calls _assert_current() on the given task and then sets the composite returncode attribute if task.returncode != os.EX_OK. If the task failed then self._current_task will be set to None. Subclasses can use this as a generic task exit callback.

Return type



The task.returncode attribute.


This calls _final_exit() and then wait().

Subclasses can use this as a generic final task exit callback.


Assumes that task is the final task of this composite task. Calls _default_exit() and sets self.returncode to the task’s returncode and sets self._current_task to None.


This does a loop calling self._current_task.poll() repeatedly as long as the value of self._current_task keeps changing. It calls poll() a maximum of one time for a given self._current_task instance. This is useful since calling poll() on a task can trigger advance to the next task could eventually lead to the returncode being set in cases when polling only a single task would not have the same effect.

_start_task(task, exit_handler)

Register exit handler for the given task, set it as self._current_task, and call task.start().

Subclasses can use this as a generic way to start a task.


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.


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


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


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


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


Future, result is self.returncode


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.


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


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


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



the value of self.returncode

portage.package.ebuild._spawn_nofetch.spawn_nofetch(portdb, ebuild_path, settings=None, fd_pipes=None)

Create a NofetchPrivateTmpdir instance, and execute it synchronously. This function must not be called from asynchronous code, since it will trigger event loop recursion which is incompatible with asyncio.