From 6026876cdfd8ffb1bde3c98e97bb7ba05ff4e4ae Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 12 Sep 2020 17:08:25 +0200 Subject: Moved parenthesis and operation in flow, Added sandbox context, Replaced subprocess wait by communicate to avoid dead lock --- src/sandbox.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/sandbox.py') diff --git a/src/sandbox.py b/src/sandbox.py index efad60c..8194556 100644 --- a/src/sandbox.py +++ b/src/sandbox.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 13:48:07 by charles #+# #+# # -# Updated: 2020/09/11 20:25:38 by charles ### ########.fr # +# Updated: 2020/09/12 17:06:28 by charles ### ########.fr # # # # ############################################################################ # @@ -14,6 +14,7 @@ import os import glob import shutil import subprocess +from contextlib import contextmanager import config @@ -35,3 +36,11 @@ def remove(): except PermissionError: subprocess.run(["chmod", "777", *glob.glob(config.SANDBOX_PATH + "/*")], check=True) subprocess.run(["rm", "-rf", config.SANDBOX_PATH], check=True) + + +@contextmanager +def context(): + """Sandbox context manager""" + create() + yield + remove() -- cgit