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
9aa78566
Commit
9aa78566
authored
Jun 05, 2019
by
Zackery Spytz
Committed by
Miss Islington (bot)
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34767: Do not always create a collections.deque() in asyncio.Lock() (GH-13834)
https://bugs.python.org/issue34767
parent
d4cf099d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
Lib/asyncio/locks.py
Lib/asyncio/locks.py
+7
-2
Misc/NEWS.d/next/Library/2019-06-04-23-44-52.bpo-34767.BpDShN.rst
...S.d/next/Library/2019-06-04-23-44-52.bpo-34767.BpDShN.rst
+1
-0
No files found.
Lib/asyncio/locks.py
View file @
9aa78566
...
...
@@ -158,7 +158,7 @@ class Lock(_ContextManagerMixin):
"""
def
__init__
(
self
,
*
,
loop
=
None
):
self
.
_waiters
=
collections
.
deque
()
self
.
_waiters
=
None
self
.
_locked
=
False
if
loop
is
not
None
:
self
.
_loop
=
loop
...
...
@@ -182,10 +182,13 @@ class Lock(_ContextManagerMixin):
This method blocks until the lock is unlocked, then sets it to
locked and returns True.
"""
if
not
self
.
_locked
and
all
(
w
.
cancelled
()
for
w
in
self
.
_waiters
):
if
(
not
self
.
_locked
and
(
self
.
_waiters
is
None
or
all
(
w
.
cancelled
()
for
w
in
self
.
_waiters
))):
self
.
_locked
=
True
return
True
if
self
.
_waiters
is
None
:
self
.
_waiters
=
collections
.
deque
()
fut
=
self
.
_loop
.
create_future
()
self
.
_waiters
.
append
(
fut
)
...
...
@@ -224,6 +227,8 @@ class Lock(_ContextManagerMixin):
def
_wake_up_first
(
self
):
"""Wake up the first waiter if it isn't done."""
if
not
self
.
_waiters
:
return
try
:
fut
=
next
(
iter
(
self
.
_waiters
))
except
StopIteration
:
...
...
Misc/NEWS.d/next/Library/2019-06-04-23-44-52.bpo-34767.BpDShN.rst
0 → 100644
View file @
9aa78566
Do not always create a :class:`collections.deque` in :class:`asyncio.Lock`.
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