Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pathos/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def getpid(target=None, host=None, all=False, **kwds):
host -- hostname where process is running
all -- get all resulting lines from query? [default = False]
'''
from numbers import Integral
if target is None:
if all:
target = ''
elif host:
raise OSError('[Error 3] No such process')
else:
return os.getpid()
elif isinstance(target, int): #NOTE: passing pid useful for all=True
elif isinstance(target, Integral): #NOTE: passing pid useful for all=True
target = "%5d " % target #NOTE: assumes max pid is 99999
#command = "ps -A | grep '%s'" % target # 'other users' only
command = "ps ax | grep '%s'" % target # 'all users'
Expand Down
3 changes: 2 additions & 1 deletion pathos/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def __init__(self, *args, **kwds):
# Create an identifier for the pool
self._id = kwds.get('id', None) #'server'
if self._id is None:
_nodes = str(ncpus) if type(ncpus) is int else '*'
from numbers import Integral
_nodes = str(ncpus) if isinstance(ncpus, Integral) else '*'
self._id = '@'.join([_nodes, '+'.join(sorted(servers))])

#XXX: throws 'socket.error' when starting > 1 server with autodetect
Expand Down
6 changes: 3 additions & 3 deletions pathos/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def __init__(self, gen=None, prefix='id-', suffix='.prof'):
self.prefix = prefix
self.suffix= suffix
#XXX: tricky: if gen is bool/str then print, else dump with gen=id_gen
if type(gen) in (bool, str):
self.sort = -1 if type(gen) is bool else gen
if (type(gen) is str) or (repr(gen) in ('True','False')):
self.sort = -1 if (repr(gen) in ('True','False')) else gen
self.pid = str
else:
self.sort = -1
Expand Down Expand Up @@ -333,7 +333,7 @@ def __init__(self, sort=None, **config):
'tottime' - internal time
"""
pipe = config.pop('pipe', None)
if type(sort) not in (bool, type(None)):
if (sort is not None) and (repr(sort) not in ('True','False')):
config.update(dict(gen=sort))
self.config = dict(gen=False) if not bool(config) else config
from pathos.pools import SerialPool
Expand Down