@@ -111,6 +111,27 @@ impl Shell {
111111
112112 /// Main loop for the Shell thread; to be invoked by the kernel.
113113 pub fn listen ( & mut self ) {
114+ #[ cfg( all( target_os = "windows" , target_arch = "aarch64" ) ) ]
115+ self . listen_polling ( ) ;
116+
117+ #[ cfg( not( all( target_os = "windows" , target_arch = "aarch64" ) ) ) ]
118+ self . listen_blocking ( ) ;
119+ }
120+
121+ /// On Windows ARM, zmq::poll with a non-zero timeout blocks forever
122+ /// and inproc notification sockets may not wake the poll. Use
123+ /// non-blocking poll with unconditional comm checks and a short sleep.
124+ #[ cfg( all( target_os = "windows" , target_arch = "aarch64" ) ) ]
125+ fn listen_polling ( & mut self ) {
126+ loop {
127+ self . process_comm_notification ( ) ;
128+ self . process_shell_socket ( ) ;
129+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 1 ) ) ;
130+ }
131+ }
132+
133+ #[ cfg( not( all( target_os = "windows" , target_arch = "aarch64" ) ) ) ]
134+ fn listen_blocking ( & mut self ) {
114135 loop {
115136 log:: trace!( "Waiting for shell messages or comm events" ) ;
116137
@@ -139,24 +160,32 @@ impl Shell {
139160 }
140161
141162 if shell_readable {
142- let message = match Message :: read_from_socket ( & self . socket ) {
143- Ok ( m) => m,
144- Err ( err) => {
145- log:: warn!( "Could not read message from shell socket: {err:?}" ) ;
146- continue ;
147- } ,
148- } ;
149-
150- // Handle the message; any failures while handling the messages are
151- // delivered to the client instead of reported up the stack, so the
152- // only errors likely here are "can't deliver to client"
153- if let Err ( err) = self . process_message ( message) {
154- log:: error!( "Could not handle shell message: {err:?}" ) ;
155- }
163+ self . process_shell_socket ( ) ;
156164 }
157165 }
158166 }
159167
168+ fn process_shell_socket ( & mut self ) {
169+ if !self . socket . has_incoming_data ( ) . unwrap_or ( false ) {
170+ return ;
171+ }
172+
173+ let message = match Message :: read_from_socket ( & self . socket ) {
174+ Ok ( m) => m,
175+ Err ( err) => {
176+ log:: warn!( "Could not read message from shell socket: {err:?}" ) ;
177+ return ;
178+ } ,
179+ } ;
180+
181+ // Handle the message; any failures while handling the messages are
182+ // delivered to the client instead of reported up the stack, so the
183+ // only errors likely here are "can't deliver to client"
184+ if let Err ( err) = self . process_message ( message) {
185+ log:: error!( "Could not handle shell message: {err:?}" ) ;
186+ }
187+ }
188+
160189 /// Process comm event notifications from the notifier thread.
161190 /// Drains all pending notifications and all pending events.
162191 fn process_comm_notification ( & mut self ) {
0 commit comments