summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/sighandler.py
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-03-27 14:30:46 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2018-04-05 14:41:58 -0400
commitc50c68fef179d9306f1a3432f48985bf20555e38 (patch)
treea1c208329a090c54a8a1f02558b2be87b830a8ab /buildscripts/resmokelib/sighandler.py
parenta5dacf7092f51055dd774a1911a48815bb9a1e0e (diff)
downloadmongo-c50c68fef179d9306f1a3432f48985bf20555e38.tar.gz
SERVER-23312 Python linting - Lint using pylint, pydocstyle & mypy
Diffstat (limited to 'buildscripts/resmokelib/sighandler.py')
-rw-r--r--buildscripts/resmokelib/sighandler.py45
1 files changed, 19 insertions, 26 deletions
diff --git a/buildscripts/resmokelib/sighandler.py b/buildscripts/resmokelib/sighandler.py
index 5da9ae52ca1..c67d44eb759 100644
--- a/buildscripts/resmokelib/sighandler.py
+++ b/buildscripts/resmokelib/sighandler.py
@@ -1,6 +1,4 @@
-"""
-Utility to support asynchronously signaling the current process.
-"""
+"""Utility to support asynchronously signaling the current process."""
from __future__ import absolute_import
@@ -12,25 +10,23 @@ import threading
import time
import traceback
-_is_windows = (sys.platform == "win32")
-if _is_windows:
+_IS_WINDOWS = (sys.platform == "win32")
+if _IS_WINDOWS:
import win32api
import win32event
-from . import reportfile
-from . import testing
+from . import reportfile # pylint: disable=wrong-import-position
+from . import testing # pylint: disable=wrong-import-position
def register(logger, suites, start_time):
- """
- On Windows, set up an event object to wait for signal, otherwise, register a signal handler
- for the SIGUSR1 signal.
- """
+ """Register an event object to wait for signal, or a signal handler for SIGUSR1."""
- def _handle_sigusr1(signum, frame):
- """
- Signal handler that will dump the stacks of all threads and
- then write out the report file and log suite summaries.
+ def _handle_sigusr1(signum, frame): # pylint: disable=unused-argument
+ """Signal handler for SIGUSR1.
+
+ The handler will dump the stacks of all threads and write out the report file and
+ log suite summaries.
"""
header_msg = "Dumping stacks due to SIGUSR1 signal"
@@ -38,9 +34,10 @@ def register(logger, suites, start_time):
_dump_and_log(header_msg)
def _handle_set_event(event_handle):
- """
- Windows event object handler that will dump the stacks of all threads and then write out
- the report file and log suite summaries.
+ """Event object handler for Windows.
+
+ The handler will dump the stacks of all threads and write out the report file and
+ log suite summaries.
"""
while True:
@@ -58,9 +55,7 @@ def register(logger, suites, start_time):
_dump_and_log(header_msg)
def _dump_and_log(header_msg):
- """
- Dumps the stacks of all threads, writes the report file, and logs the suite summaries.
- """
+ """Dump the stacks of all threads, write report file, and log suite summaries."""
_dump_stacks(logger, header_msg)
reportfile.write(suites)
@@ -68,7 +63,7 @@ def register(logger, suites, start_time):
# On Windows spawn a thread to wait on an event object for signal to dump stacks. For Cygwin
# platforms, we use a signal handler since it supports POSIX signals.
- if _is_windows:
+ if _IS_WINDOWS:
# Create unique event_name.
event_name = "Global\\Mongo_Python_" + str(os.getpid())
@@ -97,14 +92,12 @@ def register(logger, suites, start_time):
def _dump_stacks(logger, header_msg):
- """
- Signal handler that will dump the stacks of all threads.
- """
+ """Signal handler that will dump the stacks of all threads."""
sb = []
sb.append(header_msg)
- frames = sys._current_frames()
+ frames = sys._current_frames() # pylint: disable=protected-access
sb.append("Total threads: %d" % (len(frames)))
sb.append("")