Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 386218 Details for
Bug 524328
dev-lang/python-2.7.7: net-dns/c-ares-1.9.1 triggers ebuild-ipc timed out during write, due to python deadlock in futex call after fork (no threads used)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bin/ebuild-ipc.py: use threading if available
bin-ebuild-ipc.py-use-threading-if-available.patch (text/plain), 3.00 KB, created by
Zac Medico
on 2014-10-08 05:23:28 UTC
(
hide
)
Description:
bin/ebuild-ipc.py: use threading if available
Filename:
MIME Type:
Creator:
Zac Medico
Created:
2014-10-08 05:23:28 UTC
Size:
3.00 KB
patch
obsolete
>From cdfda00c5d2e08fc8693f44c349619870002968e Mon Sep 17 00:00:00 2001 >From: Zac Medico <zmedico@gentoo.org> >Date: Tue, 7 Oct 2014 21:52:08 -0700 >Subject: [PATCH] bin/ebuild-ipc.py: use threading if available > >If threading is available then use a thread instead of a fork for >writing to the fifo. This has the advantage of avoiding a possible >python futex deadlock following fork as reported in bug #524328. > >X-Gentoo-Bug: 524328 >X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524328 >--- > bin/ebuild-ipc.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 46 insertions(+), 1 deletion(-) > >diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py >index 3e6d90c..0aaec72 100755 >--- a/bin/ebuild-ipc.py >+++ b/bin/ebuild-ipc.py >@@ -5,6 +5,7 @@ > # This is a helper which ebuild processes can use > # to communicate with portage's main python process. > >+import dummy_threading > import logging > import os > import pickle >@@ -13,6 +14,11 @@ import signal > import sys > import time > >+try: >+ import threading >+except ImportError: >+ threading = dummy_threading >+ > def debug_signal(signum, frame): > import pdb > pdb.set_trace() >@@ -46,9 +52,10 @@ portage._disable_legacy_globals() > > from portage.util._async.ForkProcess import ForkProcess > from portage.util._eventloop.global_event_loop import global_event_loop >+from _emerge.AbstractPollTask import AbstractPollTask > from _emerge.PipeReader import PipeReader > >-class FifoWriter(ForkProcess): >+class FifoWriterFork(ForkProcess): > > __slots__ = ('buf', 'fifo',) > >@@ -58,6 +65,38 @@ class FifoWriter(ForkProcess): > f.write(self.buf) > return os.EX_OK > >+class FifoWriterThread(AbstractPollTask): >+ >+ __slots__ = ('buf', 'fifo', '_thread',) >+ >+ def _start(self): >+ self._registered = True >+ self._thread = threading.Thread(target=self._write_fifo) >+ self._thread.daemon = True >+ self._thread.start() >+ >+ def _write_fifo(self): >+ with open(self.fifo, 'wb', 0) as f: >+ f.write(self.buf) >+ # Thread-safe callback to EventLoop >+ self.scheduler.timeout_add(0, self._write_fifo_cb, os.EX_OK) >+ >+ def _write_fifo_cb(self, returncode): >+ self.returncode = returncode >+ self._unregister() >+ self.wait() >+ return False >+ >+ def _cancel(self): >+ # There's currently no way to force thread termination. >+ pass >+ >+ def _unregister(self): >+ self._registered = False >+ if self._thread is not None: >+ self._thread.join() >+ self._thread = None >+ > class EbuildIpc(object): > > # Timeout for each individual communication attempt (we retry >@@ -210,6 +249,12 @@ class EbuildIpc(object): > # considerations. This helps to avoid possible race conditions > # from interference between timeouts and blocking IO operations. > msg = portage.localization._('during write') >+ if threading is dummy_threading: >+ # Try to avoid this fork due to possible >+ # python deadlock (bug #524328). >+ FifoWriter = FifoWriterFork >+ else: >+ FifoWriter = FifoWriterThread > retval = self._run_writer(FifoWriter(buf=pickle.dumps(args), > fifo=self.ipc_in_fifo, scheduler=global_event_loop()), msg) > >-- >1.8.5.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 524328
:
385966
|
385968
|
385970
|
386198
|
386218
|
386272
|
386316