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
03616f9f
Commit
03616f9f
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
more coverage
parent
086d1a66
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
satella/coding/concurrent/thread.py
+4
-0
4 additions, 0 deletions
satella/coding/concurrent/thread.py
satella/opentracing/trace.py
+3
-1
3 additions, 1 deletion
satella/opentracing/trace.py
tests/test_opentracing.py
+14
-1
14 additions, 1 deletion
tests/test_opentracing.py
with
21 additions
and
2 deletions
satella/coding/concurrent/thread.py
+
4
−
0
View file @
03616f9f
...
...
@@ -21,6 +21,9 @@ def call_in_separate_thread(*t_args, delay: float = 0, **t_kwargs):
The decorated routine will return a Future that is waitable to get the result
(or the exception) of the function.
The returned Future will have an extra argument,
"
thread
"
that links to the thread
instance spawned.
The arguments given here will be passed to thread
'
s constructor, so use like:
:param delay: seconds to wait before launching function
...
...
@@ -38,6 +41,7 @@ def call_in_separate_thread(*t_args, delay: float = 0, **t_kwargs):
def
__init__
(
self
):
self
.
future
=
Future
()
super
().
__init__
(
*
t_args
,
**
t_kwargs
)
self
.
future
.
thread
=
self
def
run
(
self
):
if
not
self
.
future
.
set_running_or_notify_cancel
():
...
...
This diff is collapsed.
Click to expand it.
satella/opentracing/trace.py
+
3
−
1
View file @
03616f9f
...
...
@@ -12,7 +12,9 @@ try:
from
opentracing
import
Span
except
ImportError
:
class
Span
:
pass
@classmethod
def
_on_error
(
cls
,
span
,
exc_type
,
value
,
traceback
):
pass
def
trace_function
(
tracer
,
name
:
str
,
tags
:
tp
.
Optional
[
dict
]
=
None
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_opentracing.py
+
14
−
1
View file @
03616f9f
import
unittest
from
satella.opentracing
import
trace_exception
from
satella.coding.concurrent
import
call_in_separate_thread
from
satella.opentracing
import
trace_exception
,
trace_future
from
unittest
import
mock
class
TestOpentracing
(
unittest
.
TestCase
):
def
test_trace_future
(
self
):
@call_in_separate_thread
()
def
test_me
():
pass
fut
=
test_me
()
span
=
mock
.
Mock
()
trace_future
(
fut
,
span
)
fut
.
result
()
fut
.
thread
.
join
()
span
.
finish
.
assert_called
()
def
test_trace_exception_none
(
self
):
trace_exception
(
None
)
...
...
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