[lxc-devel] attach_wait and threads
Serge Hallyn
serge.hallyn at ubuntu.com
Mon Jul 7 13:53:35 UTC 2014
Quoting Dorian Eikenberg (Dorian.Eikenberg at uni-duesseldorf.de):
> 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:
>
Could you please add a Signed-off-by line? You can add
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
below that.
The lxc part of the api code is thread-safe, so if there is a more
general way to tell python to always allow threads, that would be
good too.
> 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>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
More information about the lxc-devel
mailing list