~ubuntu-branches/ubuntu/trusty/python-eventlet/trusty-proposed

« back to all changes in this revision

Viewing changes to eventlet/event.py

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2010-09-28 21:20:32 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100928212032-c4n67olxdoqzygmt
Tags: 0.9.12-0ubuntu1
New upstream release. (FFe: LP: #645899)

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
                    waiter.throw(*exc)
168
168
 
169
169
    def send_exception(self, *args):
170
 
        """Same as :meth:`send`, but sends an exception to waiters."""
 
170
        """Same as :meth:`send`, but sends an exception to waiters.
 
171
        
 
172
        The arguments to send_exception are the same as the arguments
 
173
        to ``raise``.  If a single exception object is passed in, it
 
174
        will be re-raised when :meth:`wait` is called, generating a
 
175
        new stacktrace.  
 
176
        
 
177
           >>> from eventlet import event
 
178
           >>> evt = event.Event()
 
179
           >>> evt.send_exception(RuntimeError())
 
180
           >>> evt.wait()
 
181
           Traceback (most recent call last):
 
182
             File "<stdin>", line 1, in <module>
 
183
             File "eventlet/event.py", line 120, in wait
 
184
               current.throw(*self._exc)
 
185
           RuntimeError
 
186
        
 
187
        If it's important to preserve the entire original stack trace,
 
188
        you must pass in the entire :func:`sys.exc_info` tuple.
 
189
 
 
190
           >>> import sys
 
191
           >>> evt = event.Event()
 
192
           >>> try:
 
193
           ...     raise RuntimeError()
 
194
           ... except RuntimeError:
 
195
           ...     evt.send_exception(*sys.exc_info())
 
196
           ... 
 
197
           >>> evt.wait()
 
198
           Traceback (most recent call last):
 
199
             File "<stdin>", line 1, in <module>
 
200
             File "eventlet/event.py", line 120, in wait
 
201
               current.throw(*self._exc)
 
202
             File "<stdin>", line 2, in <module>
 
203
           RuntimeError
 
204
           
 
205
        Note that doing so stores a traceback object directly on the
 
206
        Event object, which may cause reference cycles. See the
 
207
        :func:`sys.exc_info` documentation.
 
208
        """
171
209
        # the arguments and the same as for greenlet.throw
172
210
        return self.send(None, args)