Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Thread handling #7

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open

Improve Thread handling #7

wants to merge 15 commits into from

Conversation

PavelLinearB
Copy link
Member

@PavelLinearB PavelLinearB commented Feb 19, 2025

workerB

✨ PR Description

Purpose: Implements a basic client-server chat system with multi-threading support and message broadcast functionality.

Main changes:

  • Created client.py with socket connection handling and message receiving/sending capabilities
  • Implemented server.py with multi-threaded client management and message broadcasting
  • Added safety features including message size limits and graceful connection handling

This description was generated by LinearB AI and Added by gitStream

Copy link

gitstream-cm bot commented Feb 20, 2025

✨ PR Review Suggestion

Bug - src/client/client.py (Line 25)

Details:

Problem: Empty data from socket.recv() is not handled properly, leading to potential infinite loop
Fix: Add check for empty chunk indicating connection closed
Why: When connection is closed, recv() returns empty bytes - needs to break the loop

                chunk = socket.recv(4096)
+                if not chunk:  # Connection closed by remote
+                    break
                data += chunk

Bug - src/server/server.py (Line 35)

Details:

Problem: Similar to client, empty data from socket.recv() is not handled properly
Fix: Add check for empty chunk to detect connection closure
Why: Prevents infinite loop when client disconnects cleanly

                    chunk = self.socket.recv(4096)
+                    if not chunk:  # Connection closed by client
+                        self.signal = False
+                        break
                    data += chunk

This review was generated by LinearB AI and Added by gitStream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant