realpython / realpython/materials

multiconn-client.py sometimes concatenates messages

オープン
#229 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Jupyter Notebook
スター
5.2k
フォーク
5.3k
平均マージ
4日 10時間
マージ済み PR(30日)
10

説明

@dbader, thanks very much for your example code.

Description of the bug

Running the multi-connection example from the python-sockets-tutorial, ie,

  • materials/python-sockets-tutorial/multiconn-client.py

sometimes, but not always, concatenates the two messages.

To Reproduce

Start the server and view the output from when the client is run (see below)

python -u multiconn-server.py 127.0.0.1 65432

  listening on ('127.0.0.1', 65432)

  accepted connection from ('127.0.0.1', 50484)
  echoing b'Message 1 from client.' to ('127.0.0.1', 50484)
  echoing b'Message 2 from client.' to ('127.0.0.1', 50484)
  closing connection to ('127.0.0.1', 50484)

  accepted connection from ('127.0.0.1', 50486)
  echoing b'Message 1 from client.Message 2 from client.' to ('127.0.0.1', 50486)
  closing connection to ('127.0.0.1', 50486)

Run the client twice with 1 connection (see below). The first run gives expected results, the second run concatenates the two messages (as can be seen below). The concatenation is also evident in the output from multiconn-server.py above.

python -u multiconn-client.py 127.0.0.1 65432 1

  starting connection 1 to ('127.0.0.1', 65432)
  sending b'Message 1 from client.' to connection 1
  sending b'Message 2 from client.' to connection 1
  received b'Message 1 from client.' from connection 1
  received b'Message 2 from client.' from connection 1
  closing connection 1

python -u multiconn-client.py 127.0.0.1 65432 1

  starting connection 1 to ('127.0.0.1', 65432)
  sending b'Message 1 from client.' to connection 1
  sending b'Message 2 from client.' to connection 1
  received b'Message 1 from client.Message 2 from client.' from connection 1
  closing connection 1

Expected behavior

The output form the second run of the multiconn-client.py should be identical to the output from the first run.

Desktop (please complete the following information):

  • OS: CentOS 7
  • Browser: Firefox
  • Version 91.2.0esr (64-bit)

Additional context
Python 3.8.0

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

materials/python-sockets-tutorial/multiconn-client.py と multiconn-server.py から始め、次に、サーバーを 127.0.0.1:65432 で実行した状態で、示されている 2 つのコマンドを使って問題を再現します。クライアントが 2 つのメッセージをどのように送受信し、サーバーがそれらをどのようにログに記録するかを追跡します;完了の条件は、2 回目の実行で 1 回目の実行と一致する形で各メッセージが個別に報告されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。