99// copyright notice, and modified files need to carry a notice indicating
1010// that they have been altered from the originals.
1111
12+ #![ allow( unused_imports) ]
1213use std:: fs:: File ;
1314use std:: fs:: OpenOptions ;
1415use std:: io:: prelude:: * ;
@@ -61,6 +62,7 @@ struct Args {
6162}
6263
6364// Handle signals, and cancel QPU job if SIGTERM is received.
65+ #[ cfg( feature = "job_cleanup" ) ]
6466async fn handle_signals ( mut signals : Signals , job : PrimitiveJob ) {
6567 while let Some ( signal) = signals. next ( ) . await {
6668 // To cancel a job, invoke scancel without --signal option. This will send
@@ -205,7 +207,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
205207 . unwrap ( ) ;
206208
207209 // scancel related signals
210+ #[ cfg( feature = "job_cleanup" ) ]
208211 let signals = Signals :: new ( [ SIGTERM , SIGCONT ] ) ?;
212+ #[ cfg( feature = "job_cleanup" ) ]
209213 let handle = signals. handle ( ) ;
210214
211215 let f = File :: open ( args. input ) . expect ( "file not found" ) ;
@@ -225,6 +229,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
225229 )
226230 . await ?;
227231
232+ #[ cfg( feature = "job_cleanup" ) ]
228233 let signals_task = tokio:: spawn ( handle_signals ( signals, primitive_job. clone ( ) ) ) ;
229234
230235 let mut succeeded: bool = true ;
@@ -250,6 +255,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
250255 "Error occurred while waiting for final state: {:?}" ,
251256 e. to_string( )
252257 ) ;
258+ #[ cfg( feature = "job_cleanup" ) ]
253259 let _ = primitive_job. cancel ( false ) . await ;
254260 succeeded = false ;
255261 }
@@ -289,10 +295,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
289295 }
290296 }
291297
292- client. delete_job ( & primitive_job. job_id ) . await ?;
298+ #[ cfg( feature = "job_cleanup" ) ]
299+ {
300+ client. delete_job ( & primitive_job. job_id ) . await ?;
293301
294- handle. close ( ) ;
295- signals_task. await ?;
302+ handle. close ( ) ;
303+ signals_task. await ?;
304+ }
296305
297306 Ok ( ( ) )
298307}
0 commit comments