aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2020-05-27 20:45:26 +0200
committerVratko Polak <vrpolak@cisco.com>2020-07-13 10:19:13 +0000
commit4e6931725c37f3242a689deb12ab2b01bc6705fe (patch)
tree21ceaa9dd97439c2530db18929b25aebba434cdc /resources
parente3e4de9a122f15fd72e1005951849d1440067d2e (diff)
Soak: Fix worker exception passing
Change-Id: I636f020e97df1b37ac8b6a30af511eebe611b56f Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/PLRsearch/PLRsearch.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/resources/libraries/python/PLRsearch/PLRsearch.py b/resources/libraries/python/PLRsearch/PLRsearch.py
index e20d293d3c..37ee468405 100644
--- a/resources/libraries/python/PLRsearch/PLRsearch.py
+++ b/resources/libraries/python/PLRsearch/PLRsearch.py
@@ -1,4 +1,4 @@
-# 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:
@@ -633,7 +633,15 @@ class PLRsearch:
and number of samples used for this iteration.
:rtype: _PartialResult
"""
- pipe.send(None)
+ # 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()