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
eb4293f3
Commit
eb4293f3
authored
Jan 22, 2008
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace spam.acquire() try: ... finally: spam.release() with "with spam:"
parent
ace82959
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
24 deletions
+8
-24
Lib/threading.py
Lib/threading.py
+8
-24
No files found.
Lib/threading.py
View file @
eb4293f3
...
...
@@ -347,27 +347,18 @@ class _Event(_Verbose):
return
self
.
__flag
def
set
(
self
):
self
.
__cond
.
acquire
()
try
:
with
self
.
__cond
:
self
.
__flag
=
True
self
.
__cond
.
notifyAll
()
finally
:
self
.
__cond
.
release
()
def
clear
(
self
):
self
.
__cond
.
acquire
()
try
:
with
self
.
__cond
:
self
.
__flag
=
False
finally
:
self
.
__cond
.
release
()
def
wait
(
self
,
timeout
=
None
):
self
.
__cond
.
acquire
()
try
:
with
self
.
__cond
:
if
not
self
.
__flag
:
self
.
__cond
.
wait
(
timeout
)
finally
:
self
.
__cond
.
release
()
# Helper to generate new thread names
_counter
=
0
...
...
@@ -531,10 +522,9 @@ class Thread(_Verbose):
pass
def
__stop
(
self
):
self
.
__block
.
acquire
()
self
.
__stopped
=
True
self
.
__block
.
notifyAll
()
self
.
__block
.
release
()
with
self
.
__block
:
self
.
__stopped
=
True
self
.
__block
.
notifyAll
()
def
__delete
(
self
):
"Remove current thread from the dict of currently running threads."
...
...
@@ -560,15 +550,12 @@ class Thread(_Verbose):
# since it isn't if dummy_threading is *not* being used then don't
# hide the exception.
_active_limbo_lock
.
acquire
()
try
:
with
_active_limbo_lock
:
try
:
del
_active
[
_get_ident
()]
except
KeyError
:
if
'dummy_threading'
not
in
_sys
.
modules
:
raise
finally
:
_active_limbo_lock
.
release
()
def
join
(
self
,
timeout
=
None
):
if
not
self
.
__initialized
:
...
...
@@ -581,8 +568,7 @@ class Thread(_Verbose):
if
__debug__
:
if
not
self
.
__stopped
:
self
.
_note
(
"%s.join(): waiting until thread stops"
,
self
)
self
.
__block
.
acquire
()
try
:
with
self
.
__block
:
if
timeout
is
None
:
while
not
self
.
__stopped
:
self
.
__block
.
wait
()
...
...
@@ -600,8 +586,6 @@ class Thread(_Verbose):
else
:
if
__debug__
:
self
.
_note
(
"%s.join(): thread stopped"
,
self
)
finally
:
self
.
__block
.
release
()
def
getName
(
self
):
assert
self
.
__initialized
,
"Thread.__init__() not called"
...
...
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