9
9
import logging
10
10
import os
11
11
import re
12
- import shlex
12
+ import shutil
13
13
import signal
14
14
import stat
15
15
import sys
16
16
import threading
17
17
import time
18
18
from signal import SIGINT
19
19
from signal import SIGTERM
20
- from subprocess import check_call
21
20
from subprocess import check_output
22
21
from subprocess import PIPE
23
22
from subprocess import Popen
27
26
import psutil
28
27
from IPython .utils .path import ensure_dir_exists
29
28
from IPython .utils .path import get_home_dir
30
- from IPython .utils .process import find_cmd
31
- from IPython .utils .process import FindCmdError
32
29
from IPython .utils .text import EvalFormatter
33
30
from ipython_genutils .encoding import DEFAULT_ENCODING
34
31
from ipython_genutils .py3compat import iteritems
@@ -994,7 +991,6 @@ def _wait(self):
994
991
else :
995
992
break
996
993
stop_data = dict (exit_code = exit_code , pid = self .pid , identifier = self .identifier )
997
- output = self .get_output ()
998
994
self .loop .add_callback (lambda : self .notify_stop (stop_data ))
999
995
1000
996
def _start_waiting (self ):
@@ -1117,18 +1113,6 @@ def _engine_cmd_default(self):
1117
1113
# unset some traits we inherit but don't use
1118
1114
remote_output_file = ""
1119
1115
1120
- @property
1121
- def engine_count (self ):
1122
- """determine engine count from `engines` dict"""
1123
- count = 0
1124
- for n in itervalues (self .engines ):
1125
- if isinstance (n , (tuple , list )):
1126
- n , args = n
1127
- if isinstance (n , dict ):
1128
- n = n ['n' ]
1129
- count += n
1130
- return count
1131
-
1132
1116
def get_output (self , remove = True ):
1133
1117
# no-op in EngineSet, EngineLaunchers take care of this
1134
1118
return ''
@@ -1174,10 +1158,7 @@ def start(self, n):
1174
1158
else :
1175
1159
port = None
1176
1160
1177
- if started_n >= requested_n :
1178
- break
1179
-
1180
- for i in range (n ):
1161
+ for i in range (min (n , requested_n - started_n )):
1181
1162
if i > 0 :
1182
1163
time .sleep (self .delay )
1183
1164
# pass all common traits to the launcher
@@ -1245,18 +1226,6 @@ def start(self, n):
1245
1226
# -----------------------------------------------------------------------------
1246
1227
1247
1228
1248
- # This is only used on Windows.
1249
- def find_job_cmd ():
1250
- if WINDOWS :
1251
- try :
1252
- return find_cmd ('job' )
1253
- except (FindCmdError , ImportError ):
1254
- # ImportError will be raised if win32api is not installed
1255
- return 'job'
1256
- else :
1257
- return 'job'
1258
-
1259
-
1260
1229
class WindowsHPCLauncher (BaseLauncher ):
1261
1230
1262
1231
job_id_regexp = CRegExp (
@@ -1276,14 +1245,11 @@ class WindowsHPCLauncher(BaseLauncher):
1276
1245
scheduler = Unicode (
1277
1246
'' , config = True , help = "The hostname of the scheduler to submit the job to."
1278
1247
)
1279
- job_cmd = Unicode (
1280
- find_job_cmd (), config = True , help = "The command for submitting jobs."
1281
- )
1248
+ job_cmd = Unicode (config = True , help = "The command for submitting jobs." )
1282
1249
1283
- def __init__ (self , work_dir = u'.' , config = None , ** kwargs ):
1284
- super (WindowsHPCLauncher , self ).__init__ (
1285
- work_dir = work_dir , config = config , ** kwargs
1286
- )
1250
+ @default ("job_cmd" )
1251
+ def _default_job (self ):
1252
+ return shutil .which ("job" ) or "job"
1287
1253
1288
1254
@property
1289
1255
def job_file (self ):
@@ -1412,7 +1378,7 @@ class BatchSystemLauncher(BaseLauncher):
1412
1378
This class also has the notion of a batch script. The ``batch_template``
1413
1379
attribute can be set to a string that is a template for the batch script.
1414
1380
This template is instantiated using string formatting. Thus the template can
1415
- use {n} fot the number of instances. Subclasses can add additional variables
1381
+ use {n} for the number of instances. Subclasses can add additional variables
1416
1382
to the template dict.
1417
1383
"""
1418
1384
0 commit comments