jupyter/terminado

FAILED terminado/tests/basic_test.py::UniqueTermTests::test_max_terminals - tornado.simple_httpclient.HTTPStreamClosedError: Stream closed w/ py3.6

mgorny opened this issue · 0 comments

The listed test fails with py3.6. Deps:

tornado                       6.0.4
ptyprocess                    0.6.0
pytest                        5.4.3
$ python3.6 -m pytest
=============================================================== test session starts ===============================================================
platform linux -- Python 3.6.10, pytest-5.4.3, py-1.8.0, pluggy-0.13.1
rootdir: /tmp/terminado
plugins: requests-mock-1.7.0, betamax-0.8.1, timeout-1.3.4, httpbin-1.0.0, xprocess-0.13.1, forked-1.1.3, xdist-1.32.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, localserver-0.5.0, services-2.0.1, backports.unittest-mock-1.5, mock-3.1.1, pyfakefs-3.7.2, flaky-3.6.1, hypothesis-5.16.0
collected 8 items                                                                                                                                 

terminado/tests/basic_test.py ......F.                                                                                                      [100%]

==================================================================== FAILURES =====================================================================
_______________________________________________________ UniqueTermTests.test_max_terminals ________________________________________________________

self = <terminado.tests.basic_test.UniqueTermTests testMethod=test_max_terminals>

    @tornado.testing.gen_test
    def test_max_terminals(self):
>       tms = yield self.get_term_clients(['/unique'] * MAX_TERMS)

terminado/tests/basic_test.py:227: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.6/site-packages/tornado/gen.py:735: in run
    value = future.result()
/usr/lib64/python3.6/site-packages/tornado/gen.py:742: in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
terminado/tests/basic_test.py:114: in get_term_clients
    tms = yield [self.get_term_client(path) for path in paths]
/usr/lib64/python3.6/site-packages/tornado/gen.py:735: in run
    value = future.result()
/usr/lib64/python3.6/site-packages/tornado/gen.py:501: in callback
    result_list.append(f.result())
/usr/lib64/python3.6/site-packages/tornado/gen.py:742: in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
terminado/tests/basic_test.py:109: in get_term_client
    ws = yield tornado.websocket.websocket_connect(request)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tornado.gen.Runner object at 0x7f5c4a852080>

    def run(self) -> None:
        """Starts or resumes the generator, running until it reaches a
        yield point that is not ready.
        """
        if self.running or self.finished:
            return
        try:
            self.running = True
            while True:
                future = self.future
                if future is None:
                    raise Exception("No pending future")
                if not future.done():
                    return
                self.future = None
                try:
                    exc_info = None
    
                    try:
>                       value = future.result()
E                       tornado.simple_httpclient.HTTPStreamClosedError: Stream closed

/usr/lib64/python3.6/site-packages/tornado/gen.py:735: HTTPStreamClosedError
---------------------------------------------------------------- Captured log call ----------------------------------------------------------------
WARNING  tornado.general:autoreload.py:129 tornado.autoreload started more than once in the same process
ERROR    tornado.general:http1connection.py:829 Uncaught exception
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 253, in _add_reader
    key = self._selector.get_key(fd)
  File "/usr/lib64/python3.6/selectors.py", line 191, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '22 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 817, in _server_request_loop
    ret = await conn.read_response(request_delegate)
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 184, in _read_message
    b"\r?\n\r?\n", max_bytes=self.params.max_header_size
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 373, in read_until_regex
    self._try_inline_read()
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 864, in _try_inline_read
    self._add_io_state(ioloop.IOLoop.READ)
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 1076, in _add_io_state
    self.io_loop.add_handler(self.fileno(), self._handle_events, self._state)
  File "/usr/lib64/python3.6/site-packages/tornado/platform/asyncio.py", line 100, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 326, in add_reader
    return self._add_reader(fd, callback, *args)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 256, in _add_reader
    (handle, None))
  File "/usr/lib64/python3.6/selectors.py", line 412, in register
    self._epoll.register(key.fd, epoll_events)
OSError: [Errno 9] Bad file descriptor
ERROR    tornado.application:ioloop.py:763 Exception in callback functools.partial(<function HTTP1ServerConnection.start_serving.<locals>.<lambda> at 0x7f5c4b08c9d8>, <Task finished coro=<HTTP1ServerConnection._server_request_loop() done, defined at /usr/lib64/python3.6/site-packages/tornado/http1connection.py:809> exception=OSError(9, 'Bad file descriptor')>)
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 253, in _add_reader
    key = self._selector.get_key(fd)
  File "/usr/lib64/python3.6/selectors.py", line 191, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '22 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 817, in _server_request_loop
    ret = await conn.read_response(request_delegate)
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 184, in _read_message
    b"\r?\n\r?\n", max_bytes=self.params.max_header_size
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 373, in read_until_regex
    self._try_inline_read()
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 864, in _try_inline_read
    self._add_io_state(ioloop.IOLoop.READ)
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 1076, in _add_io_state
    self.io_loop.add_handler(self.fileno(), self._handle_events, self._state)
  File "/usr/lib64/python3.6/site-packages/tornado/platform/asyncio.py", line 100, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 326, in add_reader
    return self._add_reader(fd, callback, *args)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 256, in _add_reader
    (handle, None))
  File "/usr/lib64/python3.6/selectors.py", line 412, in register
    self._epoll.register(key.fd, epoll_events)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 807, in <lambda>
    self.stream.io_loop.add_future(fut, lambda f: f.result())
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 830, in _server_request_loop
    conn.close()
  File "/usr/lib64/python3.6/site-packages/tornado/http1connection.py", line 342, in close
    self.stream.close()
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 624, in close
    self.close_fd()
  File "/usr/lib64/python3.6/site-packages/tornado/iostream.py", line 1149, in close_fd
    self.socket.close()
  File "/usr/lib64/python3.6/socket.py", line 417, in close
    self._real_close()
  File "/usr/lib64/python3.6/socket.py", line 411, in _real_close
    _ss.close(self)
OSError: [Errno 9] Bad file descriptor
ERROR    tornado.application:web.py:1792 Uncaught exception GET /unique (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:41739', method='GET', uri='/unique', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/tornado/websocket.py", line 956, in _accept_connection
    open_result = handler.open(*handler.open_args, **handler.open_kwargs)
  File "/tmp/terminado/terminado/websocket.py", line 58, in open
    self.terminal = self.term_manager.get_terminal(url_component)
  File "/tmp/terminado/terminado/management.py", line 268, in get_terminal
    self.start_reading(term)
  File "/tmp/terminado/terminado/management.py", line 178, in start_reading
    self.ioloop.add_handler(fd, self.pty_read, self.ioloop.READ)
  File "/usr/lib64/python3.6/site-packages/tornado/platform/asyncio.py", line 97, in add_handler
    raise ValueError("fd %s added twice" % fd)
ValueError: fd 21 added twice
ERROR    tornado.application:gen.py:506 Multiple exceptions in yield list
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/tornado/gen.py", line 501, in callback
    result_list.append(f.result())
  File "/usr/lib64/python3.6/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/tmp/terminado/terminado/tests/basic_test.py", line 109, in get_term_client
    ws = yield tornado.websocket.websocket_connect(request)
  File "/usr/lib64/python3.6/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
tornado.simple_httpclient.HTTPStreamClosedError: Stream closed
================================================================ warnings summary =================================================================
terminado/tests/basic_test.py:32
  /tmp/terminado/terminado/tests/basic_test.py:32: PytestCollectionWarning: cannot collect test class 'TestTermClient' because it has a __init__ constructor (from: terminado/tests/basic_test.py)
    class TestTermClient(object):

-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================================================= short test summary info =============================================================
FAILED terminado/tests/basic_test.py::UniqueTermTests::test_max_terminals - tornado.simple_httpclient.HTTPStreamClosedError: Stream closed
===================================================== 1 failed, 7 passed, 1 warning in 36.20s =====================================================