File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,16 @@ def _recv(self):
46
46
(Parse it.)
47
47
"""
48
48
# Read next chunk.
49
- data = self .connection .recv (1024 )
49
+ try :
50
+ data = self .connection .recv (1024 )
51
+ except OSError as e :
52
+ # On OSX, when we try to create a new window by typing "pymux
53
+ # new-window" in a centain pane, very often we get the following
54
+ # error: "OSError: [Errno 9] Bad file descriptor."
55
+ # This doesn't seem very harmful, and we can just try again.
56
+ logger .warning ('Got OSError while reading data from client: %s. '
57
+ 'Trying again.' , e )
58
+ return
50
59
51
60
if data == b'' :
52
61
# End of file. Close connection.
@@ -65,7 +74,13 @@ def _process(self, data):
65
74
"""
66
75
Process packet received from client.
67
76
"""
68
- packet = json .loads (data .decode ('utf-8' ))
77
+ try :
78
+ packet = json .loads (data .decode ('utf-8' ))
79
+ except ValueError :
80
+ # So far, this never happened. But it would be good to have some
81
+ # protection.
82
+ logger .warning ('Received invalid JSON from client. Ignoring.' )
83
+ return
69
84
70
85
# Handle commands.
71
86
if packet ['cmd' ] == 'run-command' :
You can’t perform that action at this time.
0 commit comments