summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2019-04-16 14:33:43 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2019-04-16 14:33:43 -0400
commit286c0312647aae2261885da3c350f2cf24ea717d (patch)
treed2c026d07af31d046f276dac29cc9f468a6fa4b9 /buildscripts/resmokelib
parentf87a44a7433199caf1f8e7b7b16238ed87f3f60a (diff)
downloadmongo-286c0312647aae2261885da3c350f2cf24ea717d.tar.gz
SERVER-40559 Python linters do not run after upgrade to Python 3
Diffstat (limited to 'buildscripts/resmokelib')
-rw-r--r--buildscripts/resmokelib/logging/handlers.py2
-rw-r--r--buildscripts/resmokelib/testing/job.py2
-rw-r--r--buildscripts/resmokelib/utils/jscomment.py6
-rw-r--r--buildscripts/resmokelib/utils/queue.py2
-rw-r--r--buildscripts/resmokelib/utils/scheduler.py66
5 files changed, 7 insertions, 71 deletions
diff --git a/buildscripts/resmokelib/logging/handlers.py b/buildscripts/resmokelib/logging/handlers.py
index 7a00dcac988..22b632ef534 100644
--- a/buildscripts/resmokelib/logging/handlers.py
+++ b/buildscripts/resmokelib/logging/handlers.py
@@ -31,6 +31,8 @@ class BufferedHandler(logging.Handler):
should be flushed. If it should, then flush() is expected to do what's needed.
"""
+ # pylint: disable=too-many-instance-attributes
+
def __init__(self, capacity, interval_secs):
"""Initialize the handler with the buffer size and timeout.
diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py
index ad2b960fe81..080c498a990 100644
--- a/buildscripts/resmokelib/testing/job.py
+++ b/buildscripts/resmokelib/testing/job.py
@@ -104,7 +104,7 @@ class Job(object): # pylint: disable=too-many-instance-attributes
@staticmethod
def _get_time():
- """Convenience method to get current time to aid in the unit testing of the _run method."""
+ """Get current time to aid in the unit testing of the _run method."""
return time.time()
def _run(self, queue, interrupt_flag):
diff --git a/buildscripts/resmokelib/utils/jscomment.py b/buildscripts/resmokelib/utils/jscomment.py
index 21d1cfa783c..8e0a1f39ce3 100644
--- a/buildscripts/resmokelib/utils/jscomment.py
+++ b/buildscripts/resmokelib/utils/jscomment.py
@@ -5,7 +5,7 @@ import re
import yaml
# TODO: use a more robust regular expression for matching tags
-_JSTEST_TAGS_RE = re.compile(b".*@tags\s*:\s*(\[[^\]]*\])", re.DOTALL)
+_JSTEST_TAGS_RE = re.compile(r".*@tags\s*:\s*(\[[^\]]*\])", re.DOTALL)
def get_tags(pathname):
@@ -27,7 +27,7 @@ def get_tags(pathname):
*/
"""
- with open(pathname, 'rb') as fp:
+ with open(pathname, 'r', encoding='utf-8') as fp:
match = _JSTEST_TAGS_RE.match(fp.read())
if match:
try:
@@ -68,7 +68,7 @@ def _strip_jscomments(string):
if isinstance(string, bytes):
string = string.decode("utf-8")
-
+
for line in string.splitlines():
# Remove leading whitespace and symbols that commonly appear in JS comments.
line = line.lstrip("\t ").lstrip("*/")
diff --git a/buildscripts/resmokelib/utils/queue.py b/buildscripts/resmokelib/utils/queue.py
index 90c57408621..88141c794d8 100644
--- a/buildscripts/resmokelib/utils/queue.py
+++ b/buildscripts/resmokelib/utils/queue.py
@@ -10,7 +10,7 @@ import queue as _queue
import time
# Exception that is raised when get_nowait() is called on an empty Queue.
-Empty = _queue.Empty
+Empty = _queue.Empty # pylint: disable=invalid-name
class Queue(_queue.Queue):
diff --git a/buildscripts/resmokelib/utils/scheduler.py b/buildscripts/resmokelib/utils/scheduler.py
deleted file mode 100644
index 9f57d0a110e..00000000000
--- a/buildscripts/resmokelib/utils/scheduler.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""Thread-safe version of sched.scheduler; the class wasn't made thread-safe until Python 3.3."""
-
-import heapq
-import sched
-import threading
-
-
-class Scheduler(sched.scheduler):
- """A thread-safe, general purpose event scheduler."""
-
- def __init__(self, timefunc, delayfunc):
- """Initialize Scheduler."""
- sched.scheduler.__init__(self, timefunc, delayfunc)
-
- # We use a recursive lock because sched.scheduler.enter() calls sched.scheduler.enterabs().
- self._queue_lock = threading.RLock()
-
- def enterabs(self, time, priority, action, argument):
- """Enterabs."""
- with self._queue_lock:
- return sched.scheduler.enterabs(self, time, priority, action, argument)
-
- def enter(self, delay, priority, action, argument):
- """Enter."""
- with self._queue_lock:
- return sched.scheduler.enter(self, delay, priority, action, argument)
-
- def cancel(self, event):
- """Cancel."""
- with self._queue_lock:
- return sched.scheduler.cancel(self, event)
-
- def empty(self):
- """Empty."""
- with self._queue_lock:
- return sched.scheduler.empty(self)
-
- # The implementation for the run() method was adapted from sched.scheduler.run() in Python 3.6.
- def run(self):
- """Run."""
- while True:
- with self._queue_lock:
- if not self._queue:
- break
-
- now = self.timefunc()
- event = self._queue[0]
-
- should_execute = event.time <= now
- if should_execute:
- heapq.heappop(self._queue)
-
- if should_execute:
- event.action(*event.argument)
-
- # sched.scheduler calls delayfunc(0) in order to yield the CPU and let other threads
- # run, so we do the same here.
- self.delayfunc(0)
- else:
- self.delayfunc(event.time - now)
-
- @property
- def queue(self):
- """Get Queue."""
- with self._queue_lock:
- return sched.scheduler.queue.fget(self)