8000 fix: plugin crash after client-side timeout by DerGary · Pull Request #82 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gimp-mcp-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __init__(self, host='localhost', port=9877):
self.context = {}
exec("from gi.repository import Gimp", self.context)
self.auto_disconnect_client = True
# One client thread per connection; a retry after a client-side timeout
# would otherwise drive the libgimp wire protocol concurrently and crash
self.command_lock = threading.Lock()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

def do_set_i18n(self, procname):
# Plugin has no translations; tell GIMP so it stops logging
Expand Down Expand Up @@ -226,7 +229,8 @@ def _handle_client(self, client):
request = str(buffer)

# print(f"Parsed request: {request}")
response = self.execute_command(request)
with self.command_lock:
response = self.execute_command(request)
print(f"response type: {type(response)}")

if isinstance(response, dict):
Expand Down
3 changes: 2 additions & 1 deletion gimp_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def connect(self):
return
try:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(10)
# 10s was too short for flattening/scaling multi-layer PSDs and 16-bit renders
self.sock.settimeout(300)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
self.sock.connect((self.host, self.port))
logger.info(f"Connected to GIMP at {self.host}:{self.port}")
except Exception as e:
Expand Down
0