Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
9c432388
Commit
9c432388
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
add kwargs
parent
dda930e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/concurrent/thread_collection.py
+17
-3
17 additions, 3 deletions
satella/coding/concurrent/thread_collection.py
with
20 additions
and
4 deletions
CHANGELOG.md
+
2
−
0
View file @
9c432388
# v2.14.46
*
added kwargs to ThreadCollection.from_class
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
9c432388
__version__
=
'
2.14.46a
1
'
__version__
=
'
2.14.46a
2
'
This diff is collapsed.
Click to expand it.
satella/coding/concurrent/thread_collection.py
+
17
−
3
View file @
9c432388
...
...
@@ -11,7 +11,7 @@ class ThreadCollection:
>>>
class
MyThread
(
Thread
):
>>>
def
__init__
(
self
,
a
):
>>>
...
>>>
tc
=
ThreadCollection
.
from_class
(
MyThread
,
[
2
,
4
,
5
])
>>>
tc
=
ThreadCollection
.
from_class
(
MyThread
,
[
2
,
4
,
5
]
,
daemon
=
True
)
>>>
tc
.
start
()
>>>
tc
.
terminate
()
>>>
tc
.
join
()
...
...
@@ -20,14 +20,28 @@ class ThreadCollection:
__slots__
=
(
'
threads
'
,
)
@classmethod
def
from_class
(
cls
,
cls_to_use
,
iteratable
)
->
'
ThreadCollection
'
:
def
from_class
(
cls
,
cls_to_use
,
iteratable
,
**
kwargs
)
->
'
ThreadCollection
'
:
"""
Build a thread collection
:param cls_to_use: class to instantiate with
:param iteratable: an iterable with the sole argument to this class
"""
return
ThreadCollection
([
cls_to_use
(
it
)
for
it
in
iteratable
])
return
ThreadCollection
([
cls_to_use
(
it
,
**
kwargs
)
for
it
in
iteratable
])
@property
def
daemon
(
self
)
->
bool
:
"""
Is any of the threads a daemon?
Also, when used a setter sets daemon attribute.
"""
return
any
(
thread
.
daemon
for
thread
in
self
.
threads
)
@daemon.setter
def
daemon
(
self
,
v
:
bool
)
->
None
:
for
thread
in
self
.
threads
:
thread
.
daemon
=
v
def
__init__
(
self
,
threads
:
tp
.
List
[
Thread
]):
self
.
threads
=
threads
...
...
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