doc: hubs: Point to the correct function in exception message
This commit is contained in:
committed by
Sergey Shepelev
parent
78009b3904
commit
447849bb44
@@ -1,4 +1,4 @@
|
||||
"""The debug module contains utilities and functions for better
|
||||
"""The debug module contains utilities and functions for better
|
||||
debugging Eventlet-powered applications."""
|
||||
|
||||
import os
|
||||
@@ -7,16 +7,16 @@ import linecache
|
||||
import re
|
||||
import inspect
|
||||
|
||||
__all__ = ['spew', 'unspew', 'format_hub_listeners', 'format_hub_timers',
|
||||
'hub_listener_stacks', 'hub_exceptions', 'tpool_exceptions',
|
||||
'hub_prevent_multiple_readers', 'hub_timer_stacks',
|
||||
__all__ = ['spew', 'unspew', 'format_hub_listeners', 'format_hub_timers',
|
||||
'hub_listener_stacks', 'hub_exceptions', 'tpool_exceptions',
|
||||
'hub_prevent_multiple_readers', 'hub_timer_stacks',
|
||||
'hub_blocking_detection']
|
||||
|
||||
_token_splitter = re.compile('\W+')
|
||||
|
||||
|
||||
class Spew(object):
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self, trace_names=None, show_values=True):
|
||||
self.trace_names = trace_names
|
||||
self.show_values = show_values
|
||||
@@ -27,7 +27,7 @@ class Spew(object):
|
||||
if '__file__' in frame.f_globals:
|
||||
filename = frame.f_globals['__file__']
|
||||
if (filename.endswith('.pyc') or
|
||||
filename.endswith('.pyo')):
|
||||
filename.endswith('.pyo')):
|
||||
filename = filename[:-1]
|
||||
name = frame.f_globals['__name__']
|
||||
line = linecache.getline(filename, lineno)
|
||||
@@ -66,8 +66,8 @@ def unspew():
|
||||
"""Remove the trace hook installed by spew.
|
||||
"""
|
||||
sys.settrace(None)
|
||||
|
||||
|
||||
|
||||
|
||||
def format_hub_listeners():
|
||||
""" Returns a formatted string of the current listeners on the current
|
||||
hub. This can be useful in determining what's going on in the event system,
|
||||
@@ -83,6 +83,7 @@ def format_hub_listeners():
|
||||
result.append(repr(l))
|
||||
return os.linesep.join(result)
|
||||
|
||||
|
||||
def format_hub_timers():
|
||||
""" Returns a formatted string of the current timers on the current
|
||||
hub. This can be useful in determining what's going on in the event system,
|
||||
@@ -94,30 +95,43 @@ def format_hub_timers():
|
||||
for l in hub.timers:
|
||||
result.append(repr(l))
|
||||
return os.linesep.join(result)
|
||||
|
||||
def hub_listener_stacks(state = False):
|
||||
"""Toggles whether or not the hub records the stack when clients register
|
||||
listeners on file descriptors. This can be useful when trying to figure
|
||||
|
||||
|
||||
def hub_listener_stacks(state=False):
|
||||
"""Toggles whether or not the hub records the stack when clients register
|
||||
listeners on file descriptors. This can be useful when trying to figure
|
||||
out what the hub is up to at any given moment. To inspect the stacks
|
||||
of the current listeners, call :func:`format_hub_listeners` at critical
|
||||
junctures in the application logic.
|
||||
"""
|
||||
from eventlet import hubs
|
||||
hubs.get_hub().set_debug_listeners(state)
|
||||
|
||||
def hub_timer_stacks(state = False):
|
||||
"""Toggles whether or not the hub records the stack when timers are set.
|
||||
To inspect the stacks of the current timers, call :func:`format_hub_timers`
|
||||
|
||||
|
||||
def hub_timer_stacks(state=False):
|
||||
"""Toggles whether or not the hub records the stack when timers are set.
|
||||
To inspect the stacks of the current timers, call :func:`format_hub_timers`
|
||||
at critical junctures in the application logic.
|
||||
"""
|
||||
from eventlet.hubs import timer
|
||||
timer._g_debug = state
|
||||
|
||||
def hub_prevent_multiple_readers(state = True):
|
||||
|
||||
def hub_prevent_multiple_readers(state=True):
|
||||
"""Toggle prevention of multiple greenlets reading from a socket
|
||||
|
||||
When multiple greenlets read from the same socket it is often hard
|
||||
to predict which greenlet will receive what data. To achieve
|
||||
resource sharing consider using ``eventlet.pools.Pool`` instead.
|
||||
|
||||
But if you really know what you are doing you can change the state
|
||||
to ``False`` to stop the hub from protecting against this mistake.
|
||||
"""
|
||||
from eventlet.hubs import hub
|
||||
hub.g_prevent_multiple_readers = state
|
||||
|
||||
def hub_exceptions(state = True):
|
||||
|
||||
|
||||
def hub_exceptions(state=True):
|
||||
"""Toggles whether the hub prints exceptions that are raised from its
|
||||
timers. This can be useful to see how greenthreads are terminating.
|
||||
"""
|
||||
@@ -125,15 +139,17 @@ def hub_exceptions(state = True):
|
||||
hubs.get_hub().set_timer_exceptions(state)
|
||||
from eventlet import greenpool
|
||||
greenpool.DEBUG = state
|
||||
|
||||
def tpool_exceptions(state = False):
|
||||
"""Toggles whether tpool itself prints exceptions that are raised from
|
||||
|
||||
|
||||
def tpool_exceptions(state=False):
|
||||
"""Toggles whether tpool itself prints exceptions that are raised from
|
||||
functions that are executed in it, in addition to raising them like
|
||||
it normally does."""
|
||||
from eventlet import tpool
|
||||
tpool.QUIET = not state
|
||||
|
||||
def hub_blocking_detection(state = False, resolution = 1):
|
||||
|
||||
def hub_blocking_detection(state=False, resolution=1):
|
||||
"""Toggles whether Eventlet makes an effort to detect blocking
|
||||
behavior in an application.
|
||||
|
||||
@@ -156,4 +172,3 @@ def hub_blocking_detection(state = False, resolution = 1):
|
||||
hubs.get_hub().debug_blocking_resolution = resolution
|
||||
if(not state):
|
||||
hubs.get_hub().block_detect_post()
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class BaseHub(object):
|
||||
"particular socket. Consider using a pools.Pool. "\
|
||||
"If you do know what you're doing and want to disable "\
|
||||
"this error, call "\
|
||||
"eventlet.debug.hub_multiple_reader_prevention(False)" % (
|
||||
"eventlet.debug.hub_prevent_multiple_readers(False)" % (
|
||||
evtype, fileno, evtype))
|
||||
# store off the second listener in another structure
|
||||
self.secondaries[evtype].setdefault(fileno, []).append(listener)
|
||||
|
||||
Reference in New Issue
Block a user