Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhc_rank
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Skillman-Lawrence
mhc_rank
Commits
4752df65
Commit
4752df65
authored
7 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
better handling of crashed workers
parent
cc1543cf
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mhcflurry/train_allele_specific_models_command.py
+21
-10
21 additions, 10 deletions
mhcflurry/train_allele_specific_models_command.py
with
21 additions
and
10 deletions
mhcflurry/train_allele_specific_models_command.py
+
21
−
10
View file @
4752df65
...
...
@@ -9,6 +9,8 @@ import time
import
traceback
import
random
from
multiprocessing
import
Pool
,
Queue
,
cpu_count
from
queue
import
Empty
from
multiprocessing.util
import
Finalize
from
functools
import
partial
from
pprint
import
pprint
...
...
@@ -181,10 +183,12 @@ def make_worker_pool(
if
initializer_kwargs_per_process
:
assert
len
(
initializer_kwargs_per_process
)
==
processes
kwargs_queue
=
Queue
()
kwargs_queue2
=
Queue
()
for
kwargs
in
initializer_kwargs_per_process
:
kwargs_queue
.
put
(
kwargs
)
kwargs_queue2
.
put
(
kwargs
)
pool_kwargs
[
"
initializer
"
]
=
worker_init_entry_point
pool_kwargs
[
"
initargs
"
]
=
(
initializer
,
kwargs_queue
)
pool_kwargs
[
"
initargs
"
]
=
(
initializer
,
kwargs_queue
,
kwargs_queue2
)
else
:
pool_kwargs
[
"
initializer
"
]
=
initializer
...
...
@@ -194,16 +198,23 @@ def make_worker_pool(
return
worker_pool
def
worker_init_entry_point
(
init_function
,
arg_queue
=
None
):
def
worker_init_entry_point
(
init_function
,
arg_queue
=
None
,
round_robin_arg_queue
=
None
):
kwargs
=
{}
if
arg_queue
:
kwargs
=
arg_queue
.
get
()
# We add the init args back to the queue so restarted workers (e.g. when
# when running with maxtasksperchild) will pickup init arguments in a
# round-robin style.
arg_queue
.
put
(
kwargs
)
else
:
kwargs
=
{}
try
:
kwargs
=
arg_queue
.
get
(
block
=
False
)
except
Empty
:
print
(
"
Argument queue empty. Using round robin arg queue.
"
)
kwargs
=
round_robin_arg_queue
.
get
(
block
=
True
)
round_robin_arg_queue
.
put
(
kwargs
)
# On exit we add the init args back to the queue so restarted workers
# (e.g. when when running with maxtasksperchild) will pickup init
# arguments from a previously exited worker.
Finalize
(
None
,
arg_queue
.
put
,
(
kwargs
,),
exitpriority
=
1
)
print
(
"
Initializing worker: %s
"
%
str
(
kwargs
))
init_function
(
**
kwargs
)
...
...
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