Printing a RunningCommand Seems to Rerun It
cupdike opened this issue · comments
cupdike commented
I've got a situation where I run a command in background but assign it to a variable so I can call wait on it. If I print the RunningCommand object, it seems to rerun the command--I can tell since the command opens a port and I then get a "port already in use" error:
def srun(command, **kwargs):
command = command.replace('\n','')
fullCommand = f"srun {command}"
return bashc(fullCommand, **kwargs)
ray_head_cr = srun(f"""
--nodes=1 --ntasks=1 -w {head_node}
~/miniconda3/bin/ray start
--head
--node-ip-address={head_node_ip}
--port={port}
--redis-password={redis_password}
--num-cpus {SLURM_CPUS_PER_TASK}
--num-gpus {SLURM_GPUS_PER_TASK}
--include-dashboard False
--block
""", _bg=True, _err_to_out=True)
print(ray_head_cr)
When I try this with a trivial command, I don't see this happening:
>>> r = sh.date(_bg=True)
>>> print(r)
Thu Mar 25 16:33:30 EDT 2021
>>> print(r)
Thu Mar 25 16:33:30 EDT 2021
Any idea why this happens?
cupdike commented
Nevermind... I was checking for processes locally but they were actually running remotely. User error.
Admin, feel free to delete this issue...