joyceerhl / vscode-pyolite

Run Python code in Jupyter notebooks on github.dev and vscode.dev/github
https://marketplace.visualstudio.com/items?itemName=joyceerhl.vscode-pyodide
77 stars 16 forks source link

Strange behavior when testing string interpolation on github.dev. #6

Open dynamicwebpaige opened 3 years ago

dynamicwebpaige commented 3 years ago

Intended behavior: Expected to see either the output ['VS Code is great!', 'VS Code is great!'] (what appears in Colab) or ['$message', '$message'] (what appears in VS Code locally, and in Codespaces) when testing string interpolation in [github.dev]() using the Pyolite extension.

message = 'VS Code is great!'
foo = !echo -e '$message\n$message'
foo

Experienced behavior: See error logs below.

Reproducible example: https://github.dev/dynamicwebpaige/githubdev-notebook-features/blob/main/Overview_of_VSCode_Notebook_Features.ipynb

Error Message:

---------------------------------------------------------------------------
BlockingIOError                           Traceback (most recent call last)
<ipython-input-2-dd18482e0536> in <module>
      1 message = 'VS Code is great!'
----> 2 foo = get_ipython().getoutput("echo -e '$message\\n$message'")
      3 foo

/lib/python3.9/site-packages/IPython/core/interactiveshell.py in getoutput(self, cmd, split, depth)
   2574             # this is *far* from a rigorous test
   2575             raise OSError("Background processes not supported.")
-> 2576         out = getoutput(self.var_expand(cmd, depth=depth+1))
   2577         if split:
   2578             out = SList(out.splitlines())

/lib/python3.9/site-packages/IPython/utils/_process_common.py in getoutput(cmd)
    128     correct order as would be seen if running the command in a terminal).
    129     """
--> 130     out = process_handler(cmd, lambda p: p.communicate()[0], subprocess.STDOUT)
    131     if out is None:
    132         return ''

/lib/python3.9/site-packages/IPython/utils/_process_common.py in process_handler(cmd, callback, stderr)
     77     if shell and os.name == 'posix' and 'SHELL' in os.environ:
     78         executable = os.environ['SHELL']
---> 79     p = subprocess.Popen(cmd, shell=shell,
     80                          executable=executable,
     81                          stdin=subprocess.PIPE,

/lib/python3.9/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
    949                             encoding=encoding, errors=errors)
    950 
--> 951             self._execute_child(args, executable, preexec_fn, close_fds,
    952                                 pass_fds, cwd, env,
    953                                 startupinfo, creationflags, shell,

/lib/python3.9/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1752                     fds_to_keep = set(pass_fds)
   1753                     fds_to_keep.add(errpipe_write)
-> 1754                     self.pid = _posixsubprocess.fork_exec(
   1755                             args, executable_list,
   1756                             close_fds, tuple(sorted(map(int, fds_to_keep))),

BlockingIOError: [Errno 6] Resource temporarily unavailable
joyceerhl commented 3 years ago

It looks like subprocess support is not available for Pyodide due to https://github.com/pyodide/pyodide/issues/548.