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
b191541b
Commit
b191541b
authored
7 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
line len
parent
07bc9587
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/instrumentation/trace_back.py
+18
-10
18 additions, 10 deletions
satella/instrumentation/trace_back.py
with
18 additions
and
10 deletions
satella/instrumentation/trace_back.py
+
18
−
10
View file @
b191541b
# coding=UTF-8
# coding=UTF-8
"""
"""
Allows you to preserve entire stack frame along with all variables (even pickles them).
Allows you to preserve entire stack frame along with all variables (even
pickles them).
After this, you can send this report somewhere. At target, it will be unpickled in a safe way
After this, you can send this report somewhere. At target, it will be unpickled
(without importing anything extra from environment). You can unpickle particular variables stored,
in a safe way
(without importing anything extra from environment). You can unpickle
particular variables stored,
but that may involve an import.
but that may involve an import.
Use in such a way:
Use in such a way:
...
@@ -70,7 +73,8 @@ class GenerationPolicy(object):
...
@@ -70,7 +73,8 @@ class GenerationPolicy(object):
"""
"""
What compression level to use to pickle this?
What compression level to use to pickle this?
:param pickledata: bytes, pickle value
:param pickledata: bytes, pickle value
:return: int, 1-9, where
"
1
"
is the fastest, and
"
9
"
is the slowest, but produces best compression
:return: int, 1-9, where
"
1
"
is the fastest, and
"
9
"
is the slowest,
but produces best compression
"""
"""
return
6
return
6
...
@@ -96,12 +100,14 @@ class StoredVariable(object):
...
@@ -96,12 +100,14 @@ class StoredVariable(object):
Attributes are:
Attributes are:
.repr - a text representation obtained using repr
.repr - a text representation obtained using repr
.typeinfo - a text representation of variable
'
s type
.typeinfo - a text representation of variable
'
s type
.pickle - bytes with pickled (optionally processed) value, or None if not available
.pickle - bytes with pickled (optionally processed) value, or None if
not available
.pickle_type - what is stored in .pickle?
.pickle_type - what is stored in .pickle?
None - nothing
None - nothing
"
pickle
"
- normal Python pickle
"
pickle
"
- normal Python pickle
"
pickle/gzip
"
- Python pickle treated with zlib.compress
"
pickle/gzip
"
- Python pickle treated with zlib.compress
"
failed
"
- could not pickle, pickle contains a text with human-readable reason
"
failed
"
- could not pickle, pickle contains a text with
human-readable reason
"""
"""
__slots__
=
(
'
repr
'
,
'
type_
'
,
'
pickle
'
,
'
pickle_type
'
)
__slots__
=
(
'
repr
'
,
'
type_
'
,
'
pickle
'
,
'
pickle_type
'
)
...
@@ -135,9 +141,10 @@ class StoredVariable(object):
...
@@ -135,9 +141,10 @@ class StoredVariable(object):
else
:
else
:
if
policy
.
should_compress
(
self
.
pickle
):
if
policy
.
should_compress
(
self
.
pickle
):
try
:
try
:
self
.
pickle
=
zlib
.
compress
(
self
.
pickle
,
self
.
pickle
=
zlib
.
compress
(
policy
.
get_compression_level
(
self
.
pickle
,
self
.
pickle
))
policy
.
get_compression_level
(
self
.
pickle
))
self
.
pickle_type
=
"
pickle/gzip
"
self
.
pickle_type
=
"
pickle/gzip
"
except
zlib
.
error
:
except
zlib
.
error
:
pass
# ok, keep normal
pass
# ok, keep normal
...
@@ -229,7 +236,8 @@ class Traceback(object):
...
@@ -229,7 +236,8 @@ class Traceback(object):
def
pretty_format
(
self
):
def
pretty_format
(
self
):
"""
"""
Return a multi-line, pretty-printed representation of all exception data.
Return a multi-line, pretty-printed representation of all exception
data.
:return: text
:return: text
"""
"""
bio
=
io
.
StringIO
()
bio
=
io
.
StringIO
()
...
...
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