public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] fedabipkgdiff: Remove busy loop when forking abipkgdiff
Date: Fri, 07 Apr 2023 20:13:34 +0200	[thread overview]
Message-ID: <87ttxrk1bl.fsf@redhat.com> (raw)

Hello,

The function abipkgdiff() introduced a busy loop instead of using
subprocess.communicate() because it was randomly hanging back in the
python2 days.

This patch removes the busy loop altogether as I could not reproduce
the hanging anymore.

	* tools/fedabipkgdiff (abipkgdiff): Remove the busy looping and
	use subprocess.communicate() instead.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 tools/fedabipkgdiff | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/tools/fedabipkgdiff b/tools/fedabipkgdiff
index 960b15a6..e9c211cf 100755
--- a/tools/fedabipkgdiff
+++ b/tools/fedabipkgdiff
@@ -1182,30 +1182,8 @@ def abipkgdiff(cmp_half1, cmp_half2):
     proc = subprocess.Popen(' '.join(cmd), shell=True,
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             universal_newlines=True)
-    # So we could have done: stdout, stderr = proc.communicate()
-    # But then the documentatin of proc.communicate says:
-    #
-    #    Note: The data read is buffered in memory, so do not use this
-    #    method if the data size is large or unlimited. "
-    #
-    # In practice, we are seeing random cases where this
-    # proc.communicate() function does *NOT* terminate and seems to be
-    # in a deadlock state.  So we are avoiding it altogether.  We are
-    # then busy looping, waiting for the spawn process to finish, and
-    # then we get its output.
-    #
-
-    sleeptime = 0.2
-    while True:
-        if proc.poll() != None:
-            break
-        time.sleep(sleeptime)
-        # cap the sleep time at 1.6s
-        if sleeptime < 2.0:
-            sleeptime = sleeptime * 2
-
-    stdout = ''.join(proc.stdout.readlines())
-    stderr = ''.join(proc.stderr.readlines())
+
+    stdout, stderr = proc.communicate()
 
     is_ok = proc.returncode == ABIDIFF_OK
     is_internal_error = proc.returncode & ABIDIFF_ERROR or proc.returncode & ABIDIFF_USAGE_ERROR
-- 
2.39.2


-- 
		Dodji


                 reply	other threads:[~2023-04-07 18:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttxrk1bl.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).