Skip to content

Commit

Permalink
Fixed issue with timedelta in heartbeat timer (PR #5987)
Browse files Browse the repository at this point in the history
# Description

There seems to be an issue with the _set_timeout function of Tornado. If timeout is a timedelta with value zero it evaluates to false [here](https://github.com/tornadoweb/tornado/blob/master/tornado/queues.py#L62) which causes issues

# Self Check:

Strike through any lines that are not applicable (`~~line~~`) then check the box

- [ ] Attached issue to pull request
- [x] Changelog entry
- [ ] Type annotations are present
- [ ] Code is clear and sufficiently documented
- [ ] No (preventable) type errors (check using make mypy or make mypy-diff)
- [ ] Sufficient test cases (reproduces the bug/tests the requested feature)
- [ ] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
- [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
  • Loading branch information
FloLey authored and inmantaci committed May 16, 2023
1 parent 3300a0a commit 428f0e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/unreleased/fix-issue-timedelta-heartbeat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: Fixed issue with timedelta in heartbeat timer
change-type: patch
destination-branches: [master, iso6]
6 changes: 4 additions & 2 deletions src/inmanta/server/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,10 @@ async def get_calls(self, no_hang: bool) -> Optional[List[common.Request]]:
if no_hang:
timeout = 0.1
else:
timeout = self._interval

timeout = self._interval if self._interval > 0.1 else 0.1
# We choose to have a minimum of 0.1 as timeout as this is also the value used for no_hang.
# Furthermore, the timeout value cannot be zero as this causes an issue with Tornado:
# https://github.com/tornadoweb/tornado/issues/3271
call = await self._queue.get(timeout=timedelta(seconds=timeout))
if call is None:
# aborting session
Expand Down

0 comments on commit 428f0e6

Please sign in to comment.