Skip to content

Conversation

@NingLu
Copy link
Owner

@NingLu NingLu commented Apr 7, 2021

CodeGuru demo

def read_lines(file):
lines = []
ip = '127.0.0.1'
f = open(file, 'r')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: f. The resource is allocated by call builtins.open. Execution paths that do not contain closure statements were detected. To prevent this resource leak, close f in a try-finally block or declare it using a with statement.

More info
View details about the with statement in the Python developer's guide (external link).


def paginated_ddb_scan_responses():
ddb = boto3.client('dynamodb')
response = ddb.scan(TableName='test')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

The API method scan returns paginated results instead of all results. Consider using the pagination API or checking one of the following keys in the response to verify that all results were returned: ExclusiveStartKey, IsTruncated, LastEvaluatedKey, NextToken.

Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants