Comment 32 for bug 1318504

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

The problem is right here:

    def _decide_on_what_to_do(self):
        if self.native.job.startup_user_interaction_required:
            logger.info(
                _("Sending ShowInteractiveUI() and not starting the job..."))
            # Ask the application to show the interaction GUI
            self._session_wrapper.ShowInteractiveUI(self)
        else:
            logger.info(_("Running %r right away"), self.native.job)

NOTE: here we're taking the result lock and call the method below:

            with self._result_lock:
                self._result_future = self._run_and_set_callback()

    def _run_and_set_callback(self):
        """
        Internal method of PrimedJobWrapper

        Starts the future for the job result, adds a callbacks to it and
        returns the future.
        """
        future = self.native.run()
        logger.info("Added callback %r to future %r", self._result_ready, future)

NOTE: here we're running under the lock and we call the add_done_callback() method. By this time the future is already executed and ready. Calling the method now calls the callback immediately. This calls the last method in the pack below

        future.add_done_callback(self._result_ready)
        logger.info("Returning")
        return future

    def _result_ready(self, result_future):
        """
        Internal method called when the result future becomes ready
        """
        logger.debug("_result_ready(%r)", result_future)

NOTE: here we try to to re-acquire the same lock. Bam. Deadlock

        with self._result_lock: