Loopingcalls doesn't blow when function executed more than timeout value

Bug #1730619 reported by Vasyl Saienko on 2017-11-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.service
Medium
Unassigned

Bug Description

When function is executed more time than timeout value, loopingcall will not blow,
the following example shows it:

>>> from oslo_service import loopingcall
>>> import time
>>> def function(sleep):
... time.sleep(sleep)
... raise loopingcall.LoopingCallDone()
...
>>> time.ctime(); timer = loopingcall.BackOffLoopingCall(function, sleep=3); resp = timer.start(timeout=5).wait(); time.ctime();
'Tue Nov 7 11:12:53 2017'
'Tue Nov 7 11:12:56 2017'
>>> time.ctime(); timer = loopingcall.BackOffLoopingCall(function, sleep=10); resp = timer.start(timeout=5).wait(); time.ctime();
'Tue Nov 7 11:12:57 2017'
'Tue Nov 7 11:13:07 2017'
>>>

By default requests doesn't have timeout value and may hung forever http://docs.python-requests.org/en/master/user/quickstart/#timeouts. Trying to wrap such request into loopingcall will not blow as expected.
Related Bug was opened in ironic-python-agent project https://bugs.launchpad.net/ironic-python-agent/+bug/1730618

Ben Nemec (bnemec) wrote :

I think the intent behind the loopingcall classes was that the timeout applied to repeated calls to the function in question, not that it would prevent the function from running longer than the timeout. However, the docstring does seem to indicate that both are valid, which needs to be addressed by either setting a timeout on the function call or clarifying the docstring so that there is no confusion about what the timeout applies to.

Changed in oslo.service:
status: New → Confirmed
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers