From 77066a0691c2fbdf60c80320cb3210ee1b191774 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 13 Jun 2016 20:55:49 +0900 Subject: Issue 19 and 17: Awful hack to ensure string-escape is loaded This hack ensures that when propagating an exception back from the child process in a chroot, the required string-escape python module is already in memory and no attempt to lazy load it in the chroot is made. --- sandboxlib/chroot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sandboxlib/chroot.py b/sandboxlib/chroot.py index 41fd4de..c0d13f8 100644 --- a/sandboxlib/chroot.py +++ b/sandboxlib/chroot.py @@ -219,6 +219,15 @@ def run_sandbox(command, cwd=None, env=None, pipe_parent, pipe_child = multiprocessing.Pipe() with mount_all(filesystem_root, extra_mounts): + + # Awful hack to ensure string-escape is loaded: + # + # this ensures that when propagating an exception back from + # the child process in a chroot, the required string-escape + # python module is already in memory and no attempt to + # lazy load it in the chroot is made. + unused = "Some Text".encode('string-escape') + process = multiprocessing.Process( target=run_command_in_chroot, args=(pipe_child, stdout, stderr, extra_mounts, filesystem_root, -- cgit v1.2.1