167
167
waiter.throw(*exc)
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.
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
177
>>> from eventlet import event
178
>>> evt = event.Event()
179
>>> evt.send_exception(RuntimeError())
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)
187
If it's important to preserve the entire original stack trace,
188
you must pass in the entire :func:`sys.exc_info` tuple.
191
>>> evt = event.Event()
193
... raise RuntimeError()
194
... except RuntimeError:
195
... evt.send_exception(*sys.exc_info())
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>
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.
171
209
# the arguments and the same as for greenlet.throw
172
210
return self.send(None, args)