realpython / realpython/materials
multiconn-client.py sometimes concatenates messages
Personne n'a encore pris cette issue.
- Langage dominant
- Jupyter Notebook
- Étoiles
- 5.2k
- Forks
- 5.3k
- Merge moyen
- 4 j 10 h
- PR mergées (30 j)
- 10
Description
@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
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par materials/python-sockets-tutorial/multiconn-client.py et multiconn-server.py, puis reproduisez le problème à l’aide des deux commandes indiquées, avec le serveur exécuté sur 127.0.0.1:65432. Suivez la manière dont le client envoie et reçoit les deux messages et dont le serveur les journalise ; c’est terminé lorsque la deuxième exécution signale chaque message séparément, comme lors de la première exécution.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- networking
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100