Skip to content

Commit

Permalink
[py2py3] fix unittests from dmwm#10289 - src
Browse files Browse the repository at this point in the history
  • Loading branch information
mapellidario committed Jun 8, 2021
1 parent 9103ff6 commit 0917dbe
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/python/WMCore/ProcessPool/ProcessPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, slaveClassName, totalSlaves, componentDir,
self.slaveClassName = slaveClassName
self.componentDir = componentDir
self.config = config
self.versionString = "python2"
self.versionString = "python3" if PY3 else "python2"

self.workers = []
self.nSlaves = totalSlaves
Expand Down Expand Up @@ -208,7 +208,10 @@ def close(self):
for i in range(self.nSlaves):
try:
encodedWork = self.jsonHandler.encode('STOP')
self.sender.send(encodedWork)
if PY3:
self.sender.send_string(encodedWork)
else:
self.sender.send(encodedWork)
except Exception as ex:
# Might be already failed. Nothing you can
# really do about that.
Expand Down Expand Up @@ -400,7 +403,7 @@ def setupDB(config, wmInit):
logging.error("Something in the way of the config path")
sys.exit(1)

with open(configPath, 'r') as f:
with open(configPath, 'rb') as f:
config = pickle.load(f)


Expand Down Expand Up @@ -443,7 +446,10 @@ def setupDB(config, wmInit):
try:
output = {'type': 'ERROR', 'msg': crashMessage}
encodedOutput = jsonHandler.encode(output)
sender.send(encodedOutput)
if PY3:
sender.send_string(encodedOutput)
else:
sender.send(encodedOutput)
logging.error("Sent error message and now breaking")
break
except Exception as ex:
Expand All @@ -456,10 +462,16 @@ def setupDB(config, wmInit):
if isinstance(output, list):
for item in output:
encodedOutput = jsonHandler.encode(item)
sender.send(encodedOutput)
if PY3:
sender.send_string(encodedOutput)
else:
sender.send(encodedOutput)
else:
encodedOutput = jsonHandler.encode(output)
sender.send(encodedOutput)
if PY3:
sender.send_string(encodedOutput)
else:
sender.send(encodedOutput)

logging.info("Process with PID %s finished" % (os.getpid()))
del jsonHandler
Expand Down

0 comments on commit 0917dbe

Please sign in to comment.