NFVBENCH-32 Check nan result values before integer casting
[nfvbench.git] / nfvbench / utils.py
index 4d9749c..fc72517 100644 (file)
@@ -17,6 +17,7 @@ import fcntl
 from functools import wraps
 import json
 from log import LOG
+from math import isnan
 import os
 import re
 import signal
@@ -141,6 +142,10 @@ def parse_flow_count(flow_count):
     return flow_count * multiplier
 
 
+def cast_integer(value):
+    return int(value) if not isnan(value) else value
+
+
 class RunLock(object):
     """
     Attempts to lock file and run current instance of NFVbench as the first,