mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-05 14:18:11 +00:00
Fix some random deadlock while running fedabipkgidiff in tests
We are seeing some random cases where the regression test runtestfedabipkgdiff.py hangs in what seems to be a deadlock. This seems to happen in fedabipkgidiff when it spawns a process to run abipkgdiff. More precisely, proc.communicate() hangs. The documentation of that function at https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate says: Note: The data read is buffered in memory, so do not use this method if the data size is large or unlimited. So this patch avoids using proc.communicate() because the output of abipkgdiff *can* be large. Rather, the patch manually waits for the the spawned abipkgdiff to finish, and then, read its output. * tools/fedabipkgdiff (abipkgidff): Do not use Popen.communicate() as it might hang if the data is large. Rather, busy wait for the abipkgdiff process to finish and then get its output. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
888cd3c376
commit
d09468b69f
@ -1021,7 +1021,25 @@ def abipkgdiff(cmp_half1, cmp_half2):
|
||||
|
||||
proc = subprocess.Popen(' '.join(cmd), shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
# 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.
|
||||
#
|
||||
|
||||
while True:
|
||||
if proc.poll() != None:
|
||||
break
|
||||
|
||||
stdout = ''.join(proc.stdout.readlines())
|
||||
stderr = ''.join(proc.stderr.readlines())
|
||||
|
||||
is_ok = proc.returncode == ABIDIFF_OK
|
||||
is_internal_error = proc.returncode & ABIDIFF_ERROR or proc.returncode & ABIDIFF_USAGE_ERROR
|
||||
|
Loading…
Reference in New Issue
Block a user