Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Chapter 21 - tcp_mojifinder.py crashes on empty search result #61

Open
@timheiko

Description

@timheiko

Issue

Ifindex.search(query) intcp_mojifinder.py returns empty result, it crashes TCP becauseasyncio.StreamWriter.writelines(data) raisesAssertionError: Data should not be empty error ifdata is an empty iterable.

How to reproduce

Start the TCP server

% ./tcp_mojifinder.py Building index.Serving on ('127.0.0.1', 2323). Hit CTRL-C to stop....

Connect to the TCP server and send a search query which returns no results, e.g.missing

% nc localhost 2323?> missing%

The TCP server terminal will spit out an error stack trace like

% ./tcp_mojifinder.py Building index.Serving on ('127.0.0.1', 2323). Hit CTRL-C to stop. From ('127.0.0.1', 63253):'missing'Unhandled exceptionin client_connected_cbtransport:<_SelectorSocketTransport fd=7 read=polling write=<idle, bufsize=0>>Traceback (most recent call last):  File"/Users/tim/projects/python/example-code-2e/21-async/mojifinder/./tcp_mojifinder.py", line 33,in finder    results = await search(query, index, writer)# <13>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/tim/projects/python/example-code-2e/21-async/mojifinder/./tcp_mojifinder.py", line 48,in search    writer.writelines(lines)# <4>~~~~~~~~~~~~~~~~~^^^^^^^  File"/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/streams.py", line 343,in writelines    self._transport.writelines(data)~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^  File"/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/selector_events.py", line 1174,in writelinesself._write_ready()~~~~~~~~~~~~~~~~~^^  File"/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/selector_events.py", line 1090,in _write_sendmsg    assert self._buffer,'Data should not be empty'           ^^^^^^^^^^^^AssertionError: Data should not be empty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp