FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102024: Reduced _idle_semaphore.release calls by jackcvr · Pull Request #102025 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 11 additions & 8 deletions Lib/concurrent/futures/thread.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _python_exit():
after_in_parent=_global_shutdown_lock.release)


class _WorkItem(object):
class _WorkItem:
def __init__(self, future, fn, args, kwargs):
self.future = future
self.fn = fn
Expand Down Expand Up @@ -78,17 +78,20 @@ def _worker(executor_reference, work_queue, initializer, initargs):
return
try:
while True:
work_item = work_queue.get(block=True)
if work_item is not None:
work_item.run()
# Delete references to object. See issue16284
del work_item

# attempt to increment idle count
try:
work_item = work_queue.get_nowait()
except queue.Empty:
# attempt to increment idle count if queue is empty
executor = executor_reference()
if executor is not None:
executor._idle_semaphore.release()
del executor
work_item = work_queue.get(block=True)

if work_item is not None:
work_item.run()
# Delete references to object. See GH-60488
del work_item
continue

executor = executor_reference()
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce calls of ``_idle_semaphore.release()`` in :func:`concurrent.futures.thread._worker`.

Back | FazBrowse Home | New Git URL