Change-Id: I636f020e97df1b37ac8b6a30af511eebe611b56f
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
and number of samples used for this iteration.
:rtype: _PartialResult
"""
and number of samples used for this iteration.
:rtype: _PartialResult
"""
+ # If worker encountered an exception, we get it in the recv below,
+ # but send will report a broken pipe.
+ # EAFP says we should ignore the error (instead of polling first).
+ # https://devblogs.microsoft.com/python
+ # /idiomatic-python-eafp-versus-lbyl/
+ try:
+ pipe.send(None)
+ except BrokenPipeError:
+ pass
if not pipe.poll(10.0):
raise RuntimeError(f"Worker {name} did not finish!")
result_or_traceback = pipe.recv()
if not pipe.poll(10.0):
raise RuntimeError(f"Worker {name} did not finish!")
result_or_traceback = pipe.recv()