ipython / ipython/ipykernel

ipykernel should not assume interactive terminal

Open
#415 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
734
Forks
412
Avg merge
1d 5h
Merged PRs (30d)
8

Description

There are a couple of places in `ipykernel` that seem assume interactive terminal

This builds automated Travis builds. See for example errors in `jupyter-incubator/sparkmagic` project in one of the PRs
https://travis-ci.org/jupyter-incubator/sparkmagic/jobs/550505401

as discussed here
https://github.com/jupyter-incubator/sparkmagic/pull/541

There are two types of exceptions in Travis logs
```
ip.showtraceback(exc_info)
File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 1868, in showtraceback
self._showtraceback(etype, value, stb)
File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 557, in _showtraceback
exc_msg = dh.session.send(dh.pub_socket, u'error', json_clean(exc_content),
AttributeError: 'NoneType' object has no attribute 'send'

```

and
```
publish_display_data(data=obj, metadata=metadata, **kwargs)
File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/IPython/core/display.py", line 120, in publish_display_data
**kwargs
File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 128, in publish
msg = self.session.msg(
AttributeError: 'NoneType' object has no attribute 'msg'
```

I think Travis runs in a non-interactive shell that's why those things fail - notice
code path has
```
File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/IPython/core/interactiveshell.py",
```

`sys.stdout.isatty()` would be false and this has to be processed in `ipykernel` / `IPython`
separately - which would indicate a non-interactive terminal (no tty).

Thank you.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.