| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | """ | |
| 6 | 6 | ||
| 7 | - import thread | ||
| 7 | + import _thread as thread | ||
| 8 | 8 | ||
| 9 | 9 | # First we need to define a reentrant lock. | |
| 10 | 10 | # This is generally useful and should probably be in a standard Python | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | """ | |
| 14 | 14 | ||
| 15 | - import sys, os, string, getopt, thread, socket, traceback | ||
| 15 | + import sys, os, string, getopt, _thread, socket, traceback | ||
| 16 | 16 | ||
| 17 | 17 | PORT = 4000 # Default port | |
| 18 | 18 | ||
@@ -52,17 +52,17 @@ def main_thread(port): | |||
| 52 | 52 | conn.close() | |
| 53 | 53 | print("Refusing connection from non-local host", addr[0], ".") | |
| 54 | 54 | continue | |
| 55 | - thread.start_new_thread(service_thread, (conn, addr)) | ||
| 55 | + _thread.start_new_thread(service_thread, (conn, addr)) | ||
| 56 | 56 | del conn, addr | |
| 57 | 57 | ||
| 58 | 58 | def service_thread(conn, addr): | |
| 59 | 59 | (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()), | ||
| 61 | 61 | caddr), end=' ') | |
| 62 | 62 | stdin = conn.makefile("r") | |
| 63 | 63 | stdout = conn.makefile("w", 0) | |
| 64 | 64 | 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=' ') | ||
| 66 | 66 | ||
| 67 | 67 | def run_interpreter(stdin, stdout): | |
| 68 | 68 | globals = {} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,7 @@ | |||
| 66 | 66 | # current implementation consumes a thread for each coroutine that | |
| 67 | 67 | # may be resumed. | |
| 68 | 68 | ||
| 69 | - import thread | ||
| 69 | + import _thread as thread | ||
| 70 | 70 | import sync | |
| 71 | 71 | ||
| 72 | 72 | class _CoEvent: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | # Generator implementation using threads | |
| 2 | 2 | ||
| 3 | - import thread | ||
| 3 | + import _thread as thread | ||
| 4 | 4 | ||
| 5 | 5 | Killed = 'Generator.Killed' | |
| 6 | 6 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ | |||
| 20 | 20 | import time | |
| 21 | 21 | import os | |
| 22 | 22 | from stat import * | |
| 23 | - import thread | ||
| 23 | + import _thread as thread | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | # Work queue class. Usage: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,7 +268,7 @@ | |||
| 268 | 268 | # if there are are no threads waiting to write. (This is a | |
| 269 | 269 | # weakness of the interface!) | |
| 270 | 270 | ||
| 271 | - import thread | ||
| 271 | + import _thread as thread | ||
| 272 | 272 | ||
| 273 | 273 | class condition: | |
| 274 | 274 | def __init__(self, lock=None): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | 16 | import sys, os, time | |
| 17 | 17 | from socket import * | |
| 18 | - import thread | ||
| 18 | + import _thread as thread | ||
| 19 | 19 | ||
| 20 | 20 | BUFSIZE = 8*1024 | |
| 21 | 21 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -351,7 +351,7 @@ in various ways. There is a separate error indicator for each thread. | |||
| 351 | 351 | be raised. It may be called without holding the interpreter lock. | |
| 352 | 352 | ||
| 353 | 353 | .. % 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. | ||
| 355 | 355 | ||
| 356 | 356 | ||
| 357 | 357 | .. cfunction:: int PySignal_SetWakeupFd(int fd) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -539,15 +539,15 @@ supports the creation of additional interpreters (using | |||
| 539 | 539 | This is a no-op when called for a second time. It is safe to call this function | |
| 540 | 540 | before calling :cfunc:`Py_Initialize`. | |
| 541 | 541 | ||
| 542 | - .. index:: module: thread | ||
| 542 | + .. index:: module: _thread | ||
| 543 | 543 | ||
| 544 | 544 | When only the main thread exists, no lock operations are needed. This is a | |
| 545 | 545 | common situation (most Python programs do not use threads), and the lock | |
| 546 | 546 | operations slow the interpreter down a bit. Therefore, the lock is not created | |
| 547 | 547 | initially. This situation is equivalent to having acquired the lock: when | |
| 548 | 548 | there is only a single thread, all object accesses are safe. Therefore, when | |
| 549 | 549 | 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 | ||
| 551 | 551 | or the lock hasn't been created yet, it calls :cfunc:`PyEval_InitThreads`. When | |
| 552 | 552 | this call returns, it is guaranteed that the lock has been created and that the | |
| 553 | 553 | calling thread has acquired it. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -488,7 +488,7 @@ type objects) *must* have the :attr:`ob_size` field. | |||
| 488 | 488 | reference cycles. A typical implementation of a :attr:`tp_traverse` function | |
| 489 | 489 | simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python | |
| 490 | 490 | objects. For example, this is function :cfunc:`local_traverse` from the | |
| 491 | - :mod:`thread` extension module:: | ||
| 491 | + :mod:`_thread` extension module:: | ||
| 492 | 492 | ||
| 493 | 493 | static int | |
| 494 | 494 | local_traverse(localobject *self, visitproc visit, void *arg) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments