@@ -1586,6 +1586,12 @@ def _cluster_id_default(self):
15861586 help = "The name of the command line program used to delete jobs." ,
15871587 )
15881588
1589+ signal_command = List (
1590+ ['' ],
1591+ config = True ,
1592+ help = "The name of the command line program used to send signals to jobs." ,
1593+ )
1594+
15891595 job_id = Unicode ().tag (to_dict = True )
15901596
15911597 job_id_regexp = CRegExp (
@@ -1616,7 +1622,7 @@ def _cluster_id_default(self):
16161622 def _queue_changed (self , change ):
16171623 self ._update_context (change )
16181624
1619- n = Integer (1 )
1625+ n = Integer (1 ). tag ( to_dict = True )
16201626
16211627 @observe ('n' )
16221628 def _n_changed (self , change ):
@@ -1643,7 +1649,7 @@ def _n_changed(self, change):
16431649 This lets you parameterize additional options,
16441650 such as wall_time with a custom template.
16451651 """ ,
1646- )
1652+ ). tag ( to_dict = True )
16471653
16481654 @default ("context" )
16491655 def _context_default (self ):
@@ -1748,26 +1754,33 @@ def start(self, n=1):
17481754
17491755 def stop (self ):
17501756 try :
1751- p = Popen (
1757+ output = check_output (
17521758 self .delete_command + [self .job_id ],
1753- env = os .environ ,
1754- stdout = PIPE ,
1755- stderr = PIPE ,
1756- )
1757- out , err = p .communicate ()
1758- output = out + err
1759- except :
1759+ stdin = None ,
1760+ ).decode (DEFAULT_ENCODING , 'replace' )
1761+ except Exception :
17601762 self .log .exception (
17611763 "Problem stopping cluster with command: %s"
17621764 % (self .delete_command + [self .job_id ])
17631765 )
17641766 output = ""
1765- output = output . decode ( DEFAULT_ENCODING , 'replace' )
1767+
17661768 self .notify_stop (
17671769 dict (job_id = self .job_id , output = output )
17681770 ) # Pass the output of the kill cmd
17691771 return output
17701772
1773+ def signal (self , sig ):
1774+ cmd = self .signal_command + [str (sig ), self .job_id ]
1775+ try :
1776+ output = check_output (
1777+ cmd ,
1778+ stdin = None ,
1779+ ).decode (DEFAULT_ENCODING , 'replace' )
1780+ except Exception :
1781+ self .log .exception ("Problem sending signal with: {shlex_join(cmd)}" )
1782+ output = ""
1783+
17711784
17721785class BatchControllerLauncher (BatchSystemLauncher , ControllerLauncher ):
17731786 @default ("program" )
@@ -1813,6 +1826,9 @@ class PBSLauncher(BatchSystemLauncher):
18131826
18141827 submit_command = List (['qsub' ], config = True , help = "The PBS submit command ['qsub']" )
18151828 delete_command = List (['qdel' ], config = True , help = "The PBS delete command ['qdel']" )
1829+ signal_command = List (
1830+ ['qsig' , '-s' ], config = True , help = "The PBS signal command ['qsig']"
1831+ )
18161832 job_id_regexp = CRegExp (
18171833 r'\d+' ,
18181834 config = True ,
@@ -1868,6 +1884,11 @@ class SlurmLauncher(BatchSystemLauncher):
18681884 delete_command = List (
18691885 ['scancel' ], config = True , help = "The slurm delete command ['scancel']"
18701886 )
1887+ signal_command = List (
1888+ ['scancel' , '-s' ],
1889+ config = True ,
1890+ help = "The slurm signal command ['scancel', '-s']" ,
1891+ )
18711892 job_id_regexp = CRegExp (
18721893 r'\d+' ,
18731894 config = True ,
@@ -2023,9 +2044,12 @@ class SGEEngineSetLauncher(SGELauncher, BatchEngineSetLauncher):
20232044class LSFLauncher (BatchSystemLauncher ):
20242045 """A BatchSystemLauncher subclass for LSF."""
20252046
2026- submit_command = List (['bsub' ], config = True , help = "The PBS submit command ['bsub']" )
2047+ submit_command = List (['bsub' ], config = True , help = "The LSF submit command ['bsub']" )
20272048 delete_command = List (
2028- ['bkill' ], config = True , help = "The PBS delete command ['bkill']"
2049+ ['bkill' ], config = True , help = "The LSF delete command ['bkill']"
2050+ )
2051+ signal_command = List (
2052+ ['bkill' , '-s' ], config = True , help = "The LSF signal command ['bkill', '-s']"
20292053 )
20302054 job_id_regexp = CRegExp (
20312055 r'\d+' ,
0 commit comments