Example #1
0
	def create_install_task(self):

		pkg = self.pkg
		build_opts = self.build_opts
		mtimedb = self.mtimedb
		scheduler = self.scheduler
		settings = self.settings
		world_atom = self.world_atom
		ldpath_mtimes = mtimedb["ldpath"]

		if pkg.installed:
			if not (build_opts.buildpkgonly or \
				build_opts.fetchonly or build_opts.pretend):

				task = PackageUninstall(background=self.background,
					ldpath_mtimes=ldpath_mtimes, opts=self.emerge_opts,
					pkg=pkg, scheduler=scheduler, settings=settings,
					world_atom=world_atom)

			else:
				task = AsynchronousTask()

		elif build_opts.fetchonly or \
			build_opts.buildpkgonly:
			task = AsynchronousTask()
		else:
			task = self._install_task.create_install_task()

		return task
Example #2
0
    def test_exit_listener_after_exit(self):
        """
        Test that callbacks can be registered via the AsynchronousTask
        addExitListener method even after the task is done, and
        verify that the callbacks are called.
        """
        loop = asyncio._wrap_loop()
        task = AsynchronousTask(scheduler=loop)
        task.start()
        loop.run_until_complete(task.async_wait())

        for i in range(3):
            event = loop.create_future()
            task.addStartListener(lambda task: event.set_result(None))
            loop.run_until_complete(event)

            event = loop.create_future()
            task.addExitListener(lambda task: event.set_result(None))
            loop.run_until_complete(event)