twisted / twisted

@@ -104,7 +104,7 @@
Loading
104 104
def getThreadID():
105 105
    if threadingmodule is None:
106 106
        return _dummyID
107 -
    return threadingmodule.currentThread().ident
107 +
    return threadingmodule.current_thread().ident
108 108
109 109
110 110
def isInIOThread():

@@ -14,6 +14,7 @@
Loading
14 14
from twisted.internet.test.reactormixins import ReactorBuilder
15 15
from twisted.python.threadable import isInIOThread
16 16
from twisted.python.threadpool import ThreadPool
17 +
from twisted.python.versions import Version
17 18
18 19
19 20
class ThreadTestsBuilder(ReactorBuilder):
@@ -109,13 +110,13 @@
Loading
109 110
        result = []
110 111
111 112
        def threadCall():
112 -
            result.append(threading.currentThread())
113 +
            result.append(threading.current_thread())
113 114
            reactor.stop()
114 115
115 116
        reactor.callLater(0, reactor.callInThread, reactor.callFromThread, threadCall)
116 117
        self.runReactor(reactor, 5)
117 118
118 -
        self.assertEqual(result, [threading.currentThread()])
119 +
        self.assertEqual(result, [threading.current_thread()])
119 120
120 121
    def test_stopThreadPool(self):
121 122
        """
@@ -220,5 +221,14 @@
Loading
220 221
        self.runReactor(reactor)
221 222
        self.assertEqual([False], results)
222 223
224 +
    def test_threadPoolCurrentThreadDeprecated(self):
225 +
        self.callDeprecated(
226 +
            version=(
227 +
                Version("Twisted", "NEXT", 0, 0),
228 +
                "threading.current_thread",
229 +
            ),
230 +
            f=ThreadPool.currentThread,
231 +
        )
232 +
223 233
224 234
globals().update(ThreadTestsBuilder.makeTestCaseClasses())

@@ -404,11 +404,11 @@
Loading
404 404
        event = threading.Event()
405 405
406 406
        def onResult(success, result):
407 -
            threadIds.append(threading.currentThread().ident)
407 +
            threadIds.append(threading.current_thread().ident)
408 408
            event.set()
409 409
410 410
        def func():
411 -
            threadIds.append(threading.currentThread().ident)
411 +
            threadIds.append(threading.current_thread().ident)
412 412
413 413
        tp = threadpool.ThreadPool(0, 1)
414 414
        tp.callInThreadWithCallback(onResult, func)

@@ -9,12 +9,14 @@
Loading
9 9
instead of creating a thread pool directly.
10 10
"""
11 11
12 -
from threading import Thread, currentThread
12 +
from threading import Thread, current_thread
13 13
from typing import List
14 14
15 15
from twisted._threads import pool as _pool
16 16
from twisted.python import context, log
17 +
from twisted.python.deprecate import deprecated
17 18
from twisted.python.failure import Failure
19 +
from twisted.python.versions import Version
18 20
19 21
WorkerStop = object()
20 22
@@ -43,7 +45,12 @@
Loading
43 45
    name = None
44 46
45 47
    threadFactory = Thread
46 -
    currentThread = staticmethod(currentThread)
48 +
    currentThread = staticmethod(
49 +
        deprecated(
50 +
            version=Version("Twisted", "NEXT", 0, 0),
51 +
            replacement="threading.current_thread",
52 +
        )(current_thread)
53 +
    )
47 54
    _pool = staticmethod(_pool)
48 55
49 56
    def __init__(self, minthreads=5, maxthreads=20, name=None):
Files Coverage
src/twisted 89.56%
Project Totals (830 files) 89.56%
lnx-3.6.7-nodeps-withcov-posix
Build #1711256469 -
lnx-pypy-3.7-alldeps-withcov-posix
Build #1711256469 -
lnx-3.6-alldeps-withcov-posix-noipv6
Build #1711256469 -
lnx-3.7-alldeps-withcov-posix
Build #1711256469 -
lnx-3.6-alldeps-withcov-posix
Build #1711256469 -
lnx-3.8-alldeps-withcov-posix
Build #1711256469 -
lnx-3.9-alldeps-withcov-posix
Build #1711256469 -
lnx-3.10.0-rc.1-alldeps-withcov-posix
Build #1711256469 -
1
#
2
# For documentation: https://docs.codecov.io/docs/codecovyml-reference
3
# Twisted settings: https://codecov.io/gh/twisted/twisted/settings/yaml
4
#
5
# We want 100% coverage for new patches to make sure we are always increasing
6
# the coverage.
7
#
8
codecov:
9
  require_ci_to_pass: yes
10
  notify:
11
    # We have at least 10 builds in GitHub Actions and 12 in Azure
12
    # and lint + mypy + docs + ReadTheDocs
13
    after_n_builds: 15
14
    wait_for_ci: yes
15

16
coverage:
17
  precision: 2
18
  round: down
19
  status:
20
    patch:
21
      default:
22
        # New code should have 100% CI coverage as the minimum
23
        # quality assurance measurement.
24
        # If there is a good reason for new code not to have coverage,
25
        # add inline pragma comments.
26
        target: 100%
27
    project:
28
      default:
29
        # Temporary allow for a bit of slack in overall code coverage due to
30
        # swinging coverage that is not triggered by changes in a PR.
31
        # See: https://twistedmatrix.com/trac/ticket/10170
32
        threshold: 0.02%
33

34

35
# We don't want to receive general PR comments about coverage.
36
# We have the commit status checks and that should be enough.
37
# See https://docs.codecov.io/docs/pull-request-comments
38
comment: false
39

40
# See https://docs.codecov.io/docs/github-checks
41
github_checks:
42
  # We want codecov to send inline PR comments for missing coverage.
43
  annotations: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading