Skip to content

Commit 2fb8094

Browse files
author
Quentin Pierre
committed
Lambda Wrapper - Homogenize comments
1 parent d41ee04 commit 2fb8094

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

datadog/threadstats/aws_lambda.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def my_lambda_handle(event, context):
1616

1717

1818
class _LambdaDecorator(object):
19-
_counter = 0 # Number of opened wrappers, flush when 0
19+
""" Decorator to automatically init & flush metrics, created for Lambda functions"""
20+
21+
# Number of opened wrappers, flush when 0
22+
_counter = 0
2023
_counter_lock = Lock()
2124
_flush_lock = Lock()
2225
_was_initialized = False
@@ -38,7 +41,8 @@ def _close(cls):
3841
with cls._counter_lock:
3942
cls._counter = cls._counter - 1
4043

41-
if cls._counter <= 0: # Flush only when all wrappers are closed
44+
# Flush only when all wrappers are closed
45+
if cls._counter <= 0:
4246
should_flush = True
4347

4448
if should_flush:

tests/performance/test_lambda_wrapper_thread_safety.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def flush_distributions(self, dists):
2424
@datadog_lambda_wrapper
2525
def wrapped_function(id):
2626
lambda_stats("dist_" + str(id), 42)
27-
time.sleep(0.001) # sleep makes the os continue another thread
27+
# sleep makes the os continue another thread
28+
time.sleep(0.001)
2829

2930
lambda_stats("common_dist", 42)
3031

tests/unit/threadstats/test_threadstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def test_metric_type(self):
749749
def test_basic_lambda_decorator(self):
750750

751751
@datadog_lambda_wrapper
752-
def basic_wrapped_function(): # Test custom_metric function
752+
def basic_wrapped_function():
753753
lambda_stats("lambda.somemetric", 100)
754754

755755
_lambda_stats.reporter = self.reporter

0 commit comments

Comments
 (0)