@@ -155,41 +155,33 @@ impl DummyFrontend {
155
155
message. send ( & self . stdin_socket ) . unwrap ( ) ;
156
156
}
157
157
158
- pub fn recv ( socket : & Socket ) -> Message {
159
- let ( tx, rx) = crossbeam:: channel:: bounded ( 1 ) ;
160
-
161
- // There is no timeout variant on our `Socket `API, and `Socket` is not
162
- // Sync, so we need to spawn a thread to handle the timeout
163
- stdext:: spawn!( "dummy_frontend_timeout" , move || {
164
- if let Err ( err) = rx. recv_timeout( std:: time:: Duration :: from_secs( 1 ) ) {
165
- eprintln!( "Timeout while receiving message: {err}" ) ;
166
-
167
- // Can't panic as this would only poison the thread
168
- std:: process:: exit( 42 ) ;
169
- }
170
- } ) ;
171
-
172
- let out = Message :: read_from_socket ( socket) . unwrap ( ) ;
173
-
174
- // Notify timeout thread we're done
175
- tx. send ( ( ) ) . unwrap ( ) ;
158
+ pub fn recv ( & self , socket : & Socket ) -> Message {
159
+ // It's important to wait with a timeout because the kernel thread might
160
+ // have panicked, preventing it from sending the expected message. The
161
+ // tests would then hang indefinitely.
162
+ //
163
+ // Note that the panic hook will still have run to record the panic, so
164
+ // we'll get expected panic information in the test output.
165
+ if socket. poll_incoming ( 1000 ) . unwrap ( ) {
166
+ return Message :: read_from_socket ( socket) . unwrap ( ) ;
167
+ }
176
168
177
- out
169
+ panic ! ( "Timeout while expecting message on socket {}" , socket . name ) ;
178
170
}
179
171
180
172
/// Receives a Jupyter message from the Shell socket
181
173
pub fn recv_shell ( & self ) -> Message {
182
- Self :: recv ( & self . shell_socket )
174
+ self . recv ( & self . shell_socket )
183
175
}
184
176
185
177
/// Receives a Jupyter message from the IOPub socket
186
178
pub fn recv_iopub ( & self ) -> Message {
187
- Self :: recv ( & self . iopub_socket )
179
+ self . recv ( & self . iopub_socket )
188
180
}
189
181
190
182
/// Receives a Jupyter message from the Stdin socket
191
183
pub fn recv_stdin ( & self ) -> Message {
192
- Self :: recv ( & self . stdin_socket )
184
+ self . recv ( & self . stdin_socket )
193
185
}
194
186
195
187
/// Receive from Shell and assert `ExecuteReply` message.
0 commit comments