@@ -1586,6 +1586,12 @@ def _cluster_id_default(self):
1586
1586
help = "The name of the command line program used to delete jobs." ,
1587
1587
)
1588
1588
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
+
1589
1595
job_id = Unicode ().tag (to_dict = True )
1590
1596
1591
1597
job_id_regexp = CRegExp (
@@ -1616,7 +1622,7 @@ def _cluster_id_default(self):
1616
1622
def _queue_changed (self , change ):
1617
1623
self ._update_context (change )
1618
1624
1619
- n = Integer (1 )
1625
+ n = Integer (1 ). tag ( to_dict = True )
1620
1626
1621
1627
@observe ('n' )
1622
1628
def _n_changed (self , change ):
@@ -1643,7 +1649,7 @@ def _n_changed(self, change):
1643
1649
This lets you parameterize additional options,
1644
1650
such as wall_time with a custom template.
1645
1651
""" ,
1646
- )
1652
+ ). tag ( to_dict = True )
1647
1653
1648
1654
@default ("context" )
1649
1655
def _context_default (self ):
@@ -1748,26 +1754,33 @@ def start(self, n=1):
1748
1754
1749
1755
def stop (self ):
1750
1756
try :
1751
- p = Popen (
1757
+ output = check_output (
1752
1758
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 :
1760
1762
self .log .exception (
1761
1763
"Problem stopping cluster with command: %s"
1762
1764
% (self .delete_command + [self .job_id ])
1763
1765
)
1764
1766
output = ""
1765
- output = output . decode ( DEFAULT_ENCODING , 'replace' )
1767
+
1766
1768
self .notify_stop (
1767
1769
dict (job_id = self .job_id , output = output )
1768
1770
) # Pass the output of the kill cmd
1769
1771
return output
1770
1772
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
+
1771
1784
1772
1785
class BatchControllerLauncher (BatchSystemLauncher , ControllerLauncher ):
1773
1786
@default ("program" )
@@ -1813,6 +1826,9 @@ class PBSLauncher(BatchSystemLauncher):
1813
1826
1814
1827
submit_command = List (['qsub' ], config = True , help = "The PBS submit command ['qsub']" )
1815
1828
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
+ )
1816
1832
job_id_regexp = CRegExp (
1817
1833
r'\d+' ,
1818
1834
config = True ,
@@ -1868,6 +1884,11 @@ class SlurmLauncher(BatchSystemLauncher):
1868
1884
delete_command = List (
1869
1885
['scancel' ], config = True , help = "The slurm delete command ['scancel']"
1870
1886
)
1887
+ signal_command = List (
1888
+ ['scancel' , '-s' ],
1889
+ config = True ,
1890
+ help = "The slurm signal command ['scancel', '-s']" ,
1891
+ )
1871
1892
job_id_regexp = CRegExp (
1872
1893
r'\d+' ,
1873
1894
config = True ,
@@ -2023,9 +2044,12 @@ class SGEEngineSetLauncher(SGELauncher, BatchEngineSetLauncher):
2023
2044
class LSFLauncher (BatchSystemLauncher ):
2024
2045
"""A BatchSystemLauncher subclass for LSF."""
2025
2046
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']" )
2027
2048
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']"
2029
2053
)
2030
2054
job_id_regexp = CRegExp (
2031
2055
r'\d+' ,
0 commit comments