Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
itminedu
snf-ganeti
Commits
116db7c7
Commit
116db7c7
authored
16 years ago
by
Iustin Pop
Browse files
Options
Downloads
Patches
Plain Diff
Small documentation updates for workerpool.py
Reviewed-by: imsnah
parent
ea03467c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/workerpool.py
+16
-15
16 additions, 15 deletions
lib/workerpool.py
with
16 additions
and
15 deletions
lib/workerpool.py
+
16
−
15
View file @
116db7c7
...
...
@@ -37,9 +37,8 @@ class BaseWorker(threading.Thread, object):
def
__init__
(
self
,
pool
,
worker_id
):
"""
Constructor for BaseWorker thread.
Args:
- pool: Parent worker pool
- worker_id: Identifier for this worker
@param pool: the parent worker pool
@param worker_id: identifier for this worker
"""
super
(
BaseWorker
,
self
).
__init__
()
...
...
@@ -137,6 +136,8 @@ class BaseWorker(threading.Thread, object):
def
RunTask
(
self
,
*
args
):
"""
Function called to start a task.
This needs to be implemented by child classes.
"""
raise
NotImplementedError
()
...
...
@@ -146,19 +147,18 @@ class WorkerPool(object):
This class is thread-safe.
Tasks are guaranteed to be started in the order in which they
'
re
added to the
pool. Due to the nature of threading, they
'
re not
guaranteed to finish in the
same order.
Tasks are guaranteed to be started in the order in which they
'
re
added to the
pool. Due to the nature of threading, they
'
re not
guaranteed to finish in the
same order.
"""
def
__init__
(
self
,
num_workers
,
worker_class
):
"""
Constructor for worker pool.
Args:
- num_workers: Number of workers to be started (dynamic resizing is not
yet implemented)
- worker_class: Class to be instantiated for workers; should derive from
BaseWorker
@param num_workers: number of workers to be started
(dynamic resizing is not yet implemented)
@param worker_class: the class to be instantiated for workers;
should derive from L{BaseWorker}
"""
# Some of these variables are accessed by BaseWorker
...
...
@@ -185,8 +185,7 @@ class WorkerPool(object):
def
AddTask
(
self
,
*
args
):
"""
Adds a task to the queue.
Args:
- *args: Arguments passed to BaseWorker.RunTask
@param args: arguments passed to L{BaseWorker.RunTask}
"""
self
.
_lock
.
acquire
()
...
...
@@ -249,6 +248,9 @@ class WorkerPool(object):
self
.
_lock
.
release
()
def
_NewWorkerIdUnlocked
(
self
):
"""
Return an identifier for a new worker.
"""
self
.
_last_worker_id
+=
1
return
self
.
_last_worker_id
...
...
@@ -311,8 +313,7 @@ class WorkerPool(object):
def
Resize
(
self
,
num_workers
):
"""
Changes the number of workers in the pool.
Args:
- num_workers: New number of workers
@param num_workers: the new number of workers
"""
self
.
_lock
.
acquire
()
...
...
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