Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

Quick hack to make %srun non-blocking. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions slurm_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,17 @@ def sview(self, line):
pass

def _execute(self, line, input=None, stderr=False):
non_blocking = ["srun"]

name = inspect.stack()[1][3]
process = Popen([name] + line.split(), stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate(input)
if stderr:
return stdout.decode("utf-8"), stderr.decode("utf-8")
else:
return stdout.decode("utf-8")

if name not in non_blocking:
stdout, stderr = process.communicate(input)
if stderr:
return stdout.decode("utf-8"), stderr.decode("utf-8")
else:
return stdout.decode("utf-8")


def load_ipython_extension(ip):
Expand Down