Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
37f5060d
Commit
37f5060d
authored
Jun 13, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix last traces of old threading API.
parent
3b6dbefe
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
25 deletions
+25
-25
Doc/includes/mp_distributing.py
Doc/includes/mp_distributing.py
+1
-1
Doc/library/queue.rst
Doc/library/queue.rst
+1
-1
Doc/library/socketserver.rst
Doc/library/socketserver.rst
+4
-4
Doc/library/threading.rst
Doc/library/threading.rst
+11
-11
Lib/decimal.py
Lib/decimal.py
+6
-6
Lib/idlelib/rpc.py
Lib/idlelib/rpc.py
+1
-1
Misc/NEWS
Misc/NEWS
+1
-1
No files found.
Doc/includes/mp_distributing.py
View file @
37f5060d
...
...
@@ -243,7 +243,7 @@ class SettableQueue(Queue.Queue):
try
:
self
.
queue
.
clear
()
self
.
queue
.
extend
(
contents
)
self
.
not_empty
.
notify
A
ll
()
self
.
not_empty
.
notify
_a
ll
()
finally
:
self
.
not_empty
.
release
()
...
...
Doc/library/queue.rst
View file @
37f5060d
...
...
@@ -147,7 +147,7 @@ Example of how to wait for enqueued tasks to be completed::
q = Queue()
for i in range(num_worker_threads):
t = Thread(target=worker)
t.set
D
aemon(True)
t.set
_d
aemon(True)
t.start()
for item in source():
...
...
Doc/library/socketserver.rst
View file @
37f5060d
...
...
@@ -480,8 +480,8 @@ An example for the :class:`ThreadingMixIn` class::
def handle(self):
data = self.request.recv(1024)
cur_thread = threading.current
T
hread()
response = "%s: %s" % (cur_thread.get
N
ame(), data)
cur_thread = threading.current
_t
hread()
response = "%s: %s" % (cur_thread.get
_n
ame(), data)
self.request.send(response)
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
...
...
@@ -506,9 +506,9 @@ An example for the :class:`ThreadingMixIn` class::
# more thread for each request
server_thread = threading.Thread(target=server.serve_forever)
# Exit the server thread when the main thread terminates
server_thread.set
D
aemon(True)
server_thread.set
_d
aemon(True)
server_thread.start()
print "Server loop running in thread:", t.get
N
ame()
print "Server loop running in thread:", t.get
_n
ame()
client(ip, port, "Hello World 1")
client(ip, port, "Hello World 2")
...
...
Doc/library/threading.rst
View file @
37f5060d
...
...
@@ -283,29 +283,29 @@ several condition variables must share the same lock.)
A condition variable has :meth:`acquire` and :meth:`release` methods that call
the corresponding methods of the associated lock. It also has a :meth:`wait`
method, and :meth:`notify` and :meth:`notify
A
ll` methods. These three must only
method, and :meth:`notify` and :meth:`notify
_a
ll` methods. These three must only
be called when the calling thread has acquired the lock, otherwise a
:exc:`RuntimeError` is raised.
The :meth:`wait` method releases the lock, and then blocks until it is awakened
by a :meth:`notify` or :meth:`notify
A
ll` call for the same condition variable in
by a :meth:`notify` or :meth:`notify
_a
ll` call for the same condition variable in
another thread. Once awakened, it re-acquires the lock and returns. It is also
possible to specify a timeout.
The :meth:`notify` method wakes up one of the threads waiting for the condition
variable, if any are waiting. The :meth:`notify
A
ll` method wakes up all threads
variable, if any are waiting. The :meth:`notify
_a
ll` method wakes up all threads
waiting for the condition variable.
Note: the :meth:`notify` and :meth:`notify
A
ll` methods don't release the lock;
Note: the :meth:`notify` and :meth:`notify
_a
ll` methods don't release the lock;
this means that the thread or threads awakened will not return from their
:meth:`wait` call immediately, but only when the thread that called
:meth:`notify` or :meth:`notify
A
ll` finally relinquishes ownership of the lock.
:meth:`notify` or :meth:`notify
_a
ll` finally relinquishes ownership of the lock.
Tip: the typical programming style using condition variables uses the lock to
synchronize access to some shared state; threads that are interested in a
particular change of state call :meth:`wait` repeatedly until they see the
desired state, while threads that modify the state call :meth:`notify` or
:meth:`notify
A
ll` when they change the state in such a way that it could
:meth:`notify
_a
ll` when they change the state in such a way that it could
possibly be a desired state for one of the waiters. For example, the following
code is a generic producer-consumer situation with unlimited buffer capacity::
...
...
@@ -322,7 +322,7 @@ code is a generic producer-consumer situation with unlimited buffer capacity::
cv.notify()
cv.release()
To choose between :meth:`notify` and :meth:`notify
A
ll`, consider whether one
To choose between :meth:`notify` and :meth:`notify
_a
ll`, consider whether one
state change can be interesting for only one or several waiting threads. E.g.
in a typical producer-consumer situation, adding one item to the buffer only
needs to wake up one consumer thread.
...
...
@@ -353,7 +353,7 @@ needs to wake up one consumer thread.
acquired the lock when this method is called, a :exc:`RuntimeError` is raised.
This method releases the underlying lock, and then blocks until it is awakened
by a :meth:`notify` or :meth:`notify
A
ll` call for the same condition variable in
by a :meth:`notify` or :meth:`notify
_a
ll` call for the same condition variable in
another thread, or until the optional timeout occurs. Once awakened or timed
out, it re-acquires the lock and returns.
...
...
@@ -490,7 +490,7 @@ An event object manages an internal flag that can be set to true with the
The internal flag is initially false.
.. method:: Event.is
S
et()
.. method:: Event.is
_s
et()
Return true if and only if the internal flag is true.
...
...
@@ -537,7 +537,7 @@ separate thread of control.
Once the thread's activity is started, the thread is considered 'alive'. It
stops being alive when its :meth:`run` method terminates -- either normally, or
by raising an unhandled exception. The :meth:`is
A
live` method tests whether the
by raising an unhandled exception. The :meth:`is
_a
live` method tests whether the
thread is alive.
Other threads can call a thread's :meth:`join` method. This blocks the calling
...
...
@@ -614,7 +614,7 @@ impossible to detect the termination of alien threads.
When the *timeout* argument is present and not ``None``, it should be a floating
point number specifying a timeout for the operation in seconds (or fractions
thereof). As :meth:`join` always returns ``None``, you must call :meth:`is
A
live`
thereof). As :meth:`join` always returns ``None``, you must call :meth:`is
_a
live`
after :meth:`join` to decide whether a timeout happened -- if the thread is
still alive, the :meth:`join` call timed out.
...
...
Lib/decimal.py
View file @
37f5060d
...
...
@@ -383,7 +383,7 @@ _condition_map = {ConversionSyntax:InvalidOperation,
# The getcontext() and setcontext() function manage access to a thread-local
# current context. Py2.4 offers direct support for thread locals. If that
# is not available, use threading.current
T
hread() which is slower but will
# is not available, use threading.current
_t
hread() which is slower but will
# work for older Pythons. If threads are not part of the build, create a
# mock threading object with threading.local() returning the module namespace.
...
...
@@ -405,15 +405,15 @@ except AttributeError:
# To fix reloading, force it to create a new context
# Old contexts have different exceptions in their dicts, making problems.
if
hasattr
(
threading
.
current
T
hread
(),
'__decimal_context__'
):
del
threading
.
current
T
hread
().
__decimal_context__
if
hasattr
(
threading
.
current
_t
hread
(),
'__decimal_context__'
):
del
threading
.
current
_t
hread
().
__decimal_context__
def
setcontext
(
context
):
"""Set this thread's context to context."""
if
context
in
(
DefaultContext
,
BasicContext
,
ExtendedContext
):
context
=
context
.
copy
()
context
.
clear_flags
()
threading
.
current
T
hread
().
__decimal_context__
=
context
threading
.
current
_t
hread
().
__decimal_context__
=
context
def
getcontext
():
"""Returns this thread's context.
...
...
@@ -423,10 +423,10 @@ except AttributeError:
New contexts are copies of DefaultContext.
"""
try
:
return
threading
.
current
T
hread
().
__decimal_context__
return
threading
.
current
_t
hread
().
__decimal_context__
except
AttributeError
:
context
=
Context
()
threading
.
current
T
hread
().
__decimal_context__
=
context
threading
.
current
_t
hread
().
__decimal_context__
=
context
return
context
else
:
...
...
Lib/idlelib/rpc.py
View file @
37f5060d
...
...
@@ -149,7 +149,7 @@ class SocketIO(object):
def
debug
(
self
,
*
args
):
if
not
self
.
debugging
:
return
s
=
self
.
location
+
" "
+
str
(
threading
.
current_thread
().
get
N
ame
())
s
=
self
.
location
+
" "
+
str
(
threading
.
current_thread
().
get
_n
ame
())
for
a
in
args
:
s
=
s
+
" "
+
str
(
a
)
print
(
s
,
file
=
sys
.
__stderr__
)
...
...
Misc/NEWS
View file @
37f5060d
...
...
@@ -175,7 +175,7 @@ Library
- The test.test_support module has been renamed to test.support.
- The threading module API
's were renamed to by
PEP 8 complaint.
- The threading module API
was renamed to be
PEP 8 complaint.
Tools/Demos
-----------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment