Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
aexecutor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Groth
aexecutor
Commits
d5b9cac6
Commit
d5b9cac6
authored
8 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
use PriorityQueue, add prioritize()
parent
4476ba66
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aexecutor/process.py
+7
-4
7 additions, 4 deletions
aexecutor/process.py
with
7 additions
and
4 deletions
aexecutor/process.py
+
7
−
4
View file @
d5b9cac6
...
...
@@ -179,7 +179,7 @@ def _add_call_item_to_queue(pending_work_items,
while
True
:
if
call_queue
.
full
()
or
work_ids
.
empty
():
return
work_id
=
work_ids
.
get_nowait
()
work_id
=
work_ids
.
get_nowait
()
[
1
]
work_item
=
pending_work_items
[
work_id
]
if
not
work_item
.
future
.
cancelled
():
...
...
@@ -354,7 +354,7 @@ class ProcessPoolExecutor(_base.Executor):
# processes anyway, so silence the tracebacks.
self
.
_call_queue
.
_ignore_epipe
=
True
self
.
_result_queue
=
multiprocessing
.
SimpleQueue
()
self
.
_work_ids
=
asyncio
.
Queue
()
self
.
_work_ids
=
asyncio
.
Priority
Queue
()
self
.
_queue_management_thread
=
None
# Map of pids to processes
self
.
_processes
=
{}
...
...
@@ -401,7 +401,7 @@ class ProcessPoolExecutor(_base.Executor):
self
.
_processes
,
self
.
_pending_work_items
)
def
submit
(
self
,
fn
,
*
args
,
**
kwargs
):
def
prioritize
(
self
,
priority
,
fn
,
*
args
,
**
kwargs
):
if
self
.
_broken
:
raise
BrokenProcessPool
(
'
A child process terminated
'
'
abruptly, the process pool is not usable anymore
'
)
...
...
@@ -412,11 +412,14 @@ class ProcessPoolExecutor(_base.Executor):
w
=
_WorkItem
(
f
,
fn
,
args
,
kwargs
)
self
.
_pending_work_items
[
self
.
_queue_count
]
=
w
self
.
_work_ids
.
put_nowait
(
self
.
_queue_count
)
self
.
_work_ids
.
put_nowait
(
(
priority
,
self
.
_queue_count
)
)
self
.
_queue_count
+=
1
self
.
_start_queue_management_thread
()
return
f
def
submit
(
self
,
fn
,
*
args
,
**
kwargs
):
return
self
.
prioritize
(
0
,
fn
,
*
args
,
**
kwargs
)
submit
.
__doc__
=
_base
.
Executor
.
submit
.
__doc__
def
map
(
self
,
fn
,
*
iterables
,
timeout
=
None
,
chunksize
=
1
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment