@@ -111,6 +111,29 @@ 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+ if self . socket . has_incoming_data ( ) . unwrap_or ( false ) {
129+ self . process_shell_socket ( ) ;
130+ }
131+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 1 ) ) ;
132+ }
133+ }
134+
135+ #[ cfg( not( all( target_os = "windows" , target_arch = "aarch64" ) ) ) ]
136+ fn listen_blocking ( & mut self ) {
114137 loop {
115138 log:: trace!( "Waiting for shell messages or comm events" ) ;
116139
@@ -139,24 +162,28 @@ impl Shell {
139162 }
140163
141164 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- }
165+ self . process_shell_socket ( ) ;
156166 }
157167 }
158168 }
159169
170+ fn process_shell_socket ( & mut self ) {
171+ let message = match Message :: read_from_socket ( & self . socket ) {
172+ Ok ( m) => m,
173+ Err ( err) => {
174+ log:: warn!( "Could not read message from shell socket: {err:?}" ) ;
175+ return ;
176+ } ,
177+ } ;
178+
179+ // Handle the message; any failures while handling the messages are
180+ // delivered to the client instead of reported up the stack, so the
181+ // only errors likely here are "can't deliver to client"
182+ if let Err ( err) = self . process_message ( message) {
183+ log:: error!( "Could not handle shell message: {err:?}" ) ;
184+ }
185+ }
186+
160187 /// Process comm event notifications from the notifier thread.
161188 /// Drains all pending notifications and all pending events.
162189 fn process_comm_notification ( & mut self ) {
0 commit comments