X Tutup
Skip to content

Commit 2067bfd

Browse files
committed
Rename thread to _thread and dummy_thread to _dummy_thread. Issue python#2875.
1 parent 3b4b45b commit 2067bfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+161
-169
lines changed

Demo/metaclasses/Synch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
"""
66

7-
import thread
7+
import _thread as thread
88

99
# First we need to define a reentrant lock.
1010
# This is generally useful and should probably be in a standard Python

Demo/pysvr/pysvr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
"""
1414

15-
import sys, os, string, getopt, thread, socket, traceback
15+
import sys, os, string, getopt, _thread, socket, traceback
1616

1717
PORT = 4000 # Default port
1818

@@ -52,17 +52,17 @@ def main_thread(port):
5252
conn.close()
5353
print("Refusing connection from non-local host", addr[0], ".")
5454
continue
55-
thread.start_new_thread(service_thread, (conn, addr))
55+
_thread.start_new_thread(service_thread, (conn, addr))
5656
del conn, addr
5757

5858
def service_thread(conn, addr):
5959
(caddr, cport) = addr
60-
print("Thread %s has connection from %s.\n" % (str(thread.get_ident()),
60+
print("Thread %s has connection from %s.\n" % (str(_thread.get_ident()),
6161
caddr), end=' ')
6262
stdin = conn.makefile("r")
6363
stdout = conn.makefile("w", 0)
6464
run_interpreter(stdin, stdout)
65-
print("Thread %s is done.\n" % str(thread.get_ident()), end=' ')
65+
print("Thread %s is done.\n" % str(_thread.get_ident()), end=' ')
6666

6767
def run_interpreter(stdin, stdout):
6868
globals = {}

Demo/threads/Coroutine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# current implementation consumes a thread for each coroutine that
6767
# may be resumed.
6868

69-
import thread
69+
import _thread as thread
7070
import sync
7171

7272
class _CoEvent:

Demo/threads/Generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generator implementation using threads
22

3-
import thread
3+
import _thread as thread
44

55
Killed = 'Generator.Killed'
66

Demo/threads/find.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import time
2121
import os
2222
from stat import *
23-
import thread
23+
import _thread as thread
2424

2525

2626
# Work queue class. Usage:

Demo/threads/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
# if there are are no threads waiting to write. (This is a
269269
# weakness of the interface!)
270270

271-
import thread
271+
import _thread as thread
272272

273273
class condition:
274274
def __init__(self, lock=None):

Demo/threads/telnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import sys, os, time
1717
from socket import *
18-
import thread
18+
import _thread as thread
1919

2020
BUFSIZE = 8*1024
2121

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ in various ways. There is a separate error indicator for each thread.
351351
be raised. It may be called without holding the interpreter lock.
352352

353353
.. % XXX This was described as obsolete, but is used in
354-
.. % thread.interrupt_main() (used from IDLE), so it's still needed.
354+
.. % _thread.interrupt_main() (used from IDLE), so it's still needed.
355355
356356
357357
.. cfunction:: int PySignal_SetWakeupFd(int fd)

Doc/c-api/init.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,15 @@ supports the creation of additional interpreters (using
539539
This is a no-op when called for a second time. It is safe to call this function
540540
before calling :cfunc:`Py_Initialize`.
541541

542-
.. index:: module: thread
542+
.. index:: module: _thread
543543

544544
When only the main thread exists, no lock operations are needed. This is a
545545
common situation (most Python programs do not use threads), and the lock
546546
operations slow the interpreter down a bit. Therefore, the lock is not created
547547
initially. This situation is equivalent to having acquired the lock: when
548548
there is only a single thread, all object accesses are safe. Therefore, when
549549
this function initializes the lock, it also acquires it. Before the Python
550-
:mod:`thread` module creates a new thread, knowing that either it has the lock
550+
:mod:`_thread` module creates a new thread, knowing that either it has the lock
551551
or the lock hasn't been created yet, it calls :cfunc:`PyEval_InitThreads`. When
552552
this call returns, it is guaranteed that the lock has been created and that the
553553
calling thread has acquired it.

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ type objects) *must* have the :attr:`ob_size` field.
488488
reference cycles. A typical implementation of a :attr:`tp_traverse` function
489489
simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python
490490
objects. For example, this is function :cfunc:`local_traverse` from the
491-
:mod:`thread` extension module::
491+
:mod:`_thread` extension module::
492492

493493
static int
494494
local_traverse(localobject *self, visitproc visit, void *arg)

0 commit comments

Comments
 (0)
X Tutup