comparison mercurial/worker.py @ 30639:d524c88511a7

py3: replace os.name with pycompat.osname (part 1 of 2) os.name returns unicodes on py3 and we have pycompat.osname which returns bytes. This series of 2 patches will change every ocurrence of os.name with pycompat.osname.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Dec 2016 00:16:52 +0530
parents a150173da1c1
children 48dea083f66d 18fb3cf572b4
comparison
equal deleted inserted replaced
30638:1c5cbf28f007 30639:d524c88511a7
14 14
15 from .i18n import _ 15 from .i18n import _
16 from . import ( 16 from . import (
17 encoding, 17 encoding,
18 error, 18 error,
19 pycompat,
19 scmutil, 20 scmutil,
20 util, 21 util,
21 ) 22 )
22 23
23 def countcpus(): 24 def countcpus():
50 return n 51 return n
51 except ValueError: 52 except ValueError:
52 raise error.Abort(_('number of cpus must be an integer')) 53 raise error.Abort(_('number of cpus must be an integer'))
53 return min(max(countcpus(), 4), 32) 54 return min(max(countcpus(), 4), 32)
54 55
55 if os.name == 'posix': 56 if pycompat.osname == 'posix':
56 _startupcost = 0.01 57 _startupcost = 0.01
57 else: 58 else:
58 _startupcost = 1e30 59 _startupcost = 1e30
59 60
60 def worthwhile(ui, costperop, nops): 61 def worthwhile(ui, costperop, nops):
184 if os.WIFEXITED(code): 185 if os.WIFEXITED(code):
185 return os.WEXITSTATUS(code) 186 return os.WEXITSTATUS(code)
186 elif os.WIFSIGNALED(code): 187 elif os.WIFSIGNALED(code):
187 return -os.WTERMSIG(code) 188 return -os.WTERMSIG(code)
188 189
189 if os.name != 'nt': 190 if pycompat.osname != 'nt':
190 _platformworker = _posixworker 191 _platformworker = _posixworker
191 _exitstatus = _posixexitstatus 192 _exitstatus = _posixexitstatus
192 193
193 def partition(lst, nslices): 194 def partition(lst, nslices):
194 '''partition a list into N slices of roughly equal size 195 '''partition a list into N slices of roughly equal size