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
3f992ea9
Commit
3f992ea9
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
added optional `delay` argument to `call_in_separate_thread`
parent
cb8637c4
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
+1
-0
1 addition, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/concurrent/thread.py
+5
-1
5 additions, 1 deletion
satella/coding/concurrent/thread.py
with
7 additions
and
2 deletions
CHANGELOG.md
+
1
−
0
View file @
3f992ea9
# v2.14.47
*
more time-related calls will accept time strings
*
added optional
`delay`
argument to
`call_in_separate_thread`
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
3f992ea9
__version__
=
'
2.14.47a
2
'
__version__
=
'
2.14.47a
3
'
This diff is collapsed.
Click to expand it.
satella/coding/concurrent/thread.py
+
5
−
1
View file @
3f992ea9
...
...
@@ -14,7 +14,7 @@ from ..typing import ExceptionList
from
...exceptions
import
ResourceLocked
,
WouldWaitMore
def
call_in_separate_thread
(
*
t_args
,
**
t_kwargs
):
def
call_in_separate_thread
(
*
t_args
,
delay
:
float
=
0
,
**
t_kwargs
):
"""
Decorator to mark given routine as callable in a separate thread.
...
...
@@ -23,6 +23,8 @@ def call_in_separate_thread(*t_args, **t_kwargs):
The arguments given here will be passed to thread
'
s constructor, so use like:
:param delay: seconds to wait before launching function
>>>
@call_in_separate_thread
(
daemon
=
True
)
>>>
def
handle_messages
():
>>>
while
True
:
...
...
@@ -40,6 +42,8 @@ def call_in_separate_thread(*t_args, **t_kwargs):
def
run
(
self
):
if
not
self
.
future
.
set_running_or_notify_cancel
():
return
if
delay
:
time
.
sleep
(
delay
)
try
:
res
=
fun
(
*
args
,
**
kwargs
)
self
.
future
.
set_result
(
res
)
...
...
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