Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
8072efdb
Commit
8072efdb
authored
Oct 08, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gevent.util: add rst markup to docstrings
parent
36175567
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
gevent/util.py
gevent/util.py
+13
-12
No files found.
gevent/util.py
View file @
8072efdb
...
...
@@ -3,21 +3,21 @@ __all__ = ['wrap_errors', 'lazy_property']
class
wrap_errors
(
object
):
"""Helper to make function return an exception, rather than raise it.
Because every exception that is unhandled by greenlet will be logged
by the hub
,
Because every exception that is unhandled by greenlet will be logged,
it is desirable to prevent non-error exceptions from leaving a greenlet.
This can done with simple
try/except construct
:
This can done with simple
``try``/``except`` construct:
:
def func1
(*args, **kwargs):
try:
return func(*args, **kwargs)
except (A, B, C), ex:
return ex
def wrapped_func
(*args, **kwargs):
try:
return func(*args, **kwargs)
except (A, B, C), ex:
return ex
wrap_errors provides a shortcut to write that in one line
:
:class:`wrap_errors` provides a shortcut to write that in one line:
:
func1
= wrap_errors((A, B, C), func)
wrapped_func
= wrap_errors((A, B, C), func)
It also preserves
__str__ and __repr__
of the original function.
It also preserves
``__str__`` and ``__repr__``
of the original function.
"""
# QQQ could also support using wrap_errors as a decorator
...
...
@@ -47,9 +47,10 @@ class wrap_errors(object):
class
lazy_property
(
object
):
'''A decorator similar to :meth:`property` that only calls the *function* once.'''
def
__init__
(
self
,
calculate_
function
):
self
.
_calculate
=
calculate_
function
def
__init__
(
self
,
function
):
self
.
_calculate
=
function
def
__get__
(
self
,
obj
,
_
=
None
):
if
obj
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment