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
de9266e0
Commit
de9266e0
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
more `ThreadCollection` methods return self, permitting writing more conciser code
parent
8f0a3499
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
CHANGELOG.md
+1
-1
1 addition, 1 deletion
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/concurrent/thread_collection.py
+21
-6
21 additions, 6 deletions
satella/coding/concurrent/thread_collection.py
with
24 additions
and
8 deletions
.gitignore
+
1
−
0
View file @
de9266e0
...
...
@@ -11,6 +11,7 @@ venv
coverage.xml
.coverage.*
.metadata
test
lock
bin/
tmp/
...
...
This diff is collapsed.
Click to expand it.
CHANGELOG.md
+
1
−
1
View file @
de9266e0
# v2.15.2
*
changed schema's file to return a file-object
*
more
`ThreadCollection`
methods return self, permitting writing more conciser code
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
de9266e0
__version__
=
'
2.15.2a
2
'
__version__
=
'
2.15.2a
3
'
This diff is collapsed.
Click to expand it.
satella/coding/concurrent/thread_collection.py
+
21
−
6
View file @
de9266e0
...
...
@@ -73,43 +73,58 @@ class ThreadCollection:
def
__init__
(
self
,
threads
:
tp
.
Sequence
[
Thread
]):
self
.
threads
=
list
(
threads
)
def
append
(
self
,
thread
:
Thread
)
->
N
on
e
:
def
append
(
self
,
thread
:
Thread
)
->
'
ThreadCollecti
on
'
:
"""
Alias for :meth:`~satella.coding.concurrent.ThreadCollection.add`
:param thread: thread to add
:returns: this thread collection instance
"""
self
.
add
(
thread
)
return
self
def
add
(
self
,
thread
:
Thread
)
->
N
on
e
:
def
add
(
self
,
thread
:
Thread
)
->
'
ThreadCollecti
on
'
:
"""
Add a thread to the collection
:param thread: thread to add
:returns: this thread collection instance
"""
self
.
threads
.
append
(
thread
)
return
self
def
start
(
self
)
->
N
on
e
:
def
start
(
self
)
->
'
ThreadCollecti
on
'
:
"""
Start all threads
:returns: this thread collection instance
"""
for
thread
in
self
.
threads
:
thread
.
start
()
return
self
def
terminate
(
self
,
*
args
,
**
kwargs
)
->
N
on
e
:
def
terminate
(
self
,
*
args
,
**
kwargs
)
->
'
ThreadCollecti
on
'
:
"""
Call terminate() on all threads that have this method
:returns: this thread collection instance
"""
for
thread
in
self
.
threads
:
try
:
thread
.
terminate
(
*
args
,
**
kwargs
)
except
AttributeError
:
pass
return
self
def
join
(
self
)
->
None
:
"""
Join all threads
"""
def
join
(
self
)
->
'
ThreadCollection
'
:
"""
Join all threads
:returns: this thread collection instance
"""
for
thread
in
self
.
threads
:
thread
.
join
()
return
self
def
is_alive
(
self
)
->
bool
:
"""
...
...
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