[lxc-devel] attach_wait and threads
Dorian Eikenberg
Dorian.Eikenberg at uni-duesseldorf.de
Sun Jul 6 17:44:19 UTC 2014
Hi,
attaching to a container using attach_wait from python-lxc blocks all other threads since it is not GIL-aware.
This can be a problem if you want to run a timer thread, which stops the container after a certain timeout has occured.
I've provided a solution below:
diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c
index 1bc977a..91c199f 100644
--- a/src/python-lxc/lxc.c
+++ b/src/python-lxc/lxc.c
@@ -581,7 +581,9 @@ Container_attach_and_possibly_wait(Container *self, PyObject *args,
goto out;
if (wait) {
+ Py_BEGIN_ALLOW_THREADS
ret = lxc_wait_for_pid_status(pid);
+ Py_END_ALLOW_THREADS
/* handle case where attach fails */
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 255)
ret = -1;
Signed-off-by: Dorian Eikenberg <dorian.eikenberg at uni-duesseldorf.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140706/0f5bab83/attachment.html>
More information about the lxc-devel
mailing list