Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
YunchuWang committed Sep 24, 2024
1 parent b7673d5 commit 9748a90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions azure_functions_worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@

# New constant for event loop profiling
PYTHON_ENABLE_EVENT_LOOP_DEBUGGING = 'PYTHON_ENABLE_EVENT_LOOP_DEBUGGING'
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD = 'PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBAK_THRESHOLD'
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD_DEFAULT = 600 # 10 minutes
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD = \
'PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBAK_THRESHOLD'
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD_DEFAULT = 600 # 10 minutes
13 changes: 7 additions & 6 deletions azure_functions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,15 @@ def update_opentelemetry_status(self):
"Cannot import OpenTelemetry libraries."
)


def _setup_event_loop_profiling(self):
if is_envvar_true(PYTHON_ENABLE_EVENT_LOOP_DEBUGGING):
self._loop.set_debug(True)
self._loop.slow_callback_duration = get_app_setting(PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD,
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD_DEFAULT) # 10 minutes in seconds
logger.info("Event loop debug mode enabled with 10-minute slow callback detection")

self._loop.slow_callback_duration = \
get_app_setting(
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD,
PYTHON_DEBUGGING_EVENT_LOOP_SLOW_CALLBACK_THRESHOLD_DEFAULT)
logger.info('Event loop debug mode enabled with 10-minute slow '
'callback detection')

async def _handle__worker_init_request(self, request):
logger.info('Received WorkerInitRequest, '
Expand Down Expand Up @@ -778,7 +779,7 @@ async def _handle__function_environment_reload_request(self, request):
os.environ[var] = env_vars[var]
# Enable event loop debug mode
self._setup_event_loop_profiling()

# Apply PYTHON_THREADPOOL_THREAD_COUNT
self._stop_sync_call_tp()
self._sync_call_tp = (
Expand Down

0 comments on commit 9748a90

Please sign in to comment.