Skip to content

Commit

Permalink
#464 get session handling refactor to take oldest session
Browse files Browse the repository at this point in the history
  • Loading branch information
liampauling committed Jul 12, 2021
1 parent 9ba19ae commit 335a159
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Release History

**Improvements**

-
- #464 get session handling refactor to take oldest session

**Bug Fixes**

- #454 SP nr size adjustment (@jsphon)
Expand Down
2 changes: 1 addition & 1 deletion flumine/execution/baseexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def execute_replace(
def _get_http_session(self) -> requests.Session:
while self._sessions:
try:
_session = self._sessions.pop()
_session = self._sessions.pop(0)
if (time.time() - _session.time_returned) > MAX_SESSION_AGE:
self._return_http_session(_session, err=True)
continue
Expand Down
2 changes: 1 addition & 1 deletion tests/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def test__get_http_session(self, mock__create_new_session):
mock_session_one = mock.Mock(time_returned=time.time())
mock_session_two = mock.Mock(time_returned=time.time())
self.execution._sessions = [mock_session_one, mock_session_two]
self.assertEqual(self.execution._get_http_session(), mock_session_two)
self.assertEqual(self.execution._get_http_session(), mock_session_one)
self.assertEqual(self.execution._get_http_session(), mock_session_two)
self.assertEqual(self.execution._get_http_session(), mock__create_new_session())

@mock.patch("flumine.execution.baseexecution.BaseExecution._return_http_session")
Expand Down

0 comments on commit 335a159

Please sign in to comment.