Closed g7gpr closed 1 year ago
What if it can't be converted to an integer, which seems to be causing the issue in the first place? It will crash the program.
Happy to write something safer if you can make a suggestion.
This is what I tested.
Current code - crash
>>> print("Int conversion {:d}".format(3.157))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'float''
Option 1 wrap in int()
>>> print("Int conversion {:d}".format(int(3.157)))
Int conversion 3
Option 2 Get rid of format code
>>> print("Int conversion {}".format(3.157))
Int conversion 3.157
Option 3 Format to float
>>> print("To float {:.2f}".format(3.157))
To float 3.16
>>>
So would you suggest putting it in a try: except: ?
Thanks! I might not be understanding the problem, but why don't we make the format float, and convert to float? If that is the type that gets passed in anyway.
I'll test that approach.
And just in case the timeout is integer, could you do float(worker_timeout) in the print? Thanks!
When running processing after capture, worker_timeout is generally not an integer, as it includes the capture duration. This change converts it to an int for logging.