A content like this
Class Tcontent:
def __init__(self, op_file):
self.op_file = op_file
async def __aenter__(self):
sbatch_cmd = f"sbatch -p test -q test -c 1 --mem 1000 -o {self.op_file} myscript.sh"
proc = await asyncio.create_subprocess_shell(sbatch_cmd, stderr=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
raise Exception
else:
with open(op_file) as tf:
out = tf.read()
return out
async def __aexit__(self, exc_type, exc_val, exc_tb):
***
Then I call it
async with Tcontent('sbatch.out') as x:
print(x)
It will raise No such file or directory sbatch.out
when I set breakpoint before with open(op_file) as tf
, then continue run, it works well