Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.
This repository was archived by the owner on Jan 23, 2020. It is now read-only.

rate_function.py can cause ZeroDivisionError #67

@pataphor

Description

@pataphor

In file ../site-packages/visual_common/rate_function.py:
Line 196:
dt = calledTime - self.lastEndRate # time spent in user code
But sometimes this results in dt becoming equal to zero.
Then, in line 199:
self.userTime = dt # the first time we have a user code time is self.count == 2
Now self.userTime is zero too.
But in line 152:
U = self.userTime
and later, in the same function, we have at line 163:
M = int(USER_FRACTION/U)
Which then will cause a ZeroDivision Error traceback

Proposed fix:

Add at line 13:
SMALLEST_FLOAT = sys.float_info.min
and at line 201:
if self.userTime == 0:
self.userTime = SMALLEST_FLOAT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions