New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect timeout warnings in AWS Lambda and GCP integrations #854
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
import logging | ||
import os | ||
import sys | ||
import time | ||
import threading | ||
|
||
from datetime import datetime | ||
|
@@ -891,21 +890,27 @@ def __init__(self, waiting_time, configured_timeout): | |
threading.Thread.__init__(self) | ||
self.waiting_time = waiting_time | ||
self.configured_timeout = configured_timeout | ||
self._stop_event = threading.Event() | ||
|
||
def stop(self): | ||
# type: () -> None | ||
self._stop_event.set() | ||
|
||
def run(self): | ||
# type: () -> None | ||
|
||
time.sleep(self.waiting_time) | ||
self._stop_event.wait(self.waiting_time) | ||
|
||
integer_configured_timeout = int(self.configured_timeout) | ||
if not self._stop_event.is_set(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rhcarvalho I made final changes, if these look okay then PR can be merged. |
||
integer_configured_timeout = int(self.configured_timeout) | ||
|
||
# Setting up the exact integer value of configured time(in seconds) | ||
if integer_configured_timeout < self.configured_timeout: | ||
integer_configured_timeout = integer_configured_timeout + 1 | ||
# Setting up the exact integer value of configured time(in seconds) | ||
if integer_configured_timeout < self.configured_timeout: | ||
integer_configured_timeout = integer_configured_timeout + 1 | ||
|
||
# Raising Exception after timeout duration is reached | ||
raise ServerlessTimeoutWarning( | ||
"WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds.".format( | ||
integer_configured_timeout | ||
# Raising Exception after timeout duration is reached | ||
raise ServerlessTimeoutWarning( | ||
"WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds.".format( | ||
integer_configured_timeout | ||
) | ||
) | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@untitaker In this "finally" block, the code to stop the thread basically works in case of :-
But, it doesn't stop the thread in case of timeout, which is an expected behavior.
By "stop the thread" I mean explicitly stopping a thread by sending a stop signal.