From d1bb8d1d49de9668e8afc697aef8166d6c5bfabe Mon Sep 17 00:00:00 2001
From: t_feng <fengtao40@huawei.com>
Date: Fri, 25 Sep 2020 23:16:04 +0800
Subject: [PATCH] add dnf transaction timeout

---
 pyanaconda/core/constants.py      | 3 +++
 pyanaconda/payload/dnf/payload.py | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/core/constants.py b/pyanaconda/core/constants.py
index 0e4cc15..607f96c 100644
--- a/pyanaconda/core/constants.py
+++ b/pyanaconda/core/constants.py
@@ -448,6 +448,9 @@ URL_TYPE_BASEURL = "BASEURL"
 URL_TYPE_MIRRORLIST = "MIRRORLIST"
 URL_TYPE_METALINK = "METALINK"
 
+#DNF trasactions timeout
+DNF_TRANSACTIONS_TIMEOUT = 1800
+
 # The default source for the DNF payload.
 DNF_DEFAULT_SOURCE_TYPE = SOURCE_TYPE_CLOSEST_MIRROR
 
diff --git a/pyanaconda/payload/dnf/payload.py b/pyanaconda/payload/dnf/payload.py
index f927208..08963cc 100644
--- a/pyanaconda/payload/dnf/payload.py
+++ b/pyanaconda/payload/dnf/payload.py
@@ -19,6 +19,7 @@
 import configparser
 import functools
 import multiprocessing
+import queue
 import os
 import shutil
 import sys
@@ -1356,7 +1357,11 @@ class DNFPayload(Payload):
                 if errors.errorHandler.cb(exc) == errors.ERROR_RAISE:
                     log.error("Installation failed: %r", exc)
                     go_to_failure_limbo()
-            (token, msg) = queue_instance.get()
+            try:
+                (token, msg) = queue_instance.get(True, constants.DNF_TRANSACTIONS_TIMEOUT)
+            except queue.Empty:
+                msg = ("Payload error - DNF installation has timeouted")
+                raise PayloadError(msg)
 
         process.join()
         # Don't close the mother base here, because we still need it.
-- 
2.23.0

