Commit Graph

6 Commits

Author SHA1 Message Date
Zack Cerza
3981a8f1af Never use 'except:' without specifying an Exception. 2013-08-30 11:10:05 -05:00
Tommi Virtanen
79607eed3c Don't lose tracebacks of exceptions raised in a greenlet.
Exception objects don't contain the traceback of where they were
raised from (to avoid cyclic data structures wrecking gc and causing
mem leaks), so the singular "raise obj" form creates a new traceback
from the current execution location, thus losing the original location
of the error.

Gevent explicitly wants to throw away the traceback, to release any
objects the greenlet may still be referring to, closing files,
releasing locks etc. In this case, we think it's safe, so stash the
exception info away in a holder object, and resurrect it on the other
side of the results queue.

http://stackoverflow.com/questions/9268916/how-to-capture-a-traceback-in-gevent

This can be reproduced easily with

	from teuthology.parallel import parallel
	def f():
	    raise RuntimeError("bork")
	with parallel() as p:
	    p.spawn(f)

and looking at the resulting traceback with and without this change.
2012-09-11 11:25:21 -07:00
Josh Durgin
b32b693ab2 parallel: obey iterator protocol
Once it raises StopIteration, it must continue to do so on subsequent calls to next().
2012-04-24 17:48:05 -07:00
Josh Durgin
f9daa70259 parallel: don't hang if no tasks were spawned
This makes 6d91915217 work.
2011-08-31 17:28:23 -07:00
Josh Durgin
9721e33457 Better interface for running functions in parallel. 2011-07-14 14:39:50 -07:00
Josh Durgin
4b245fce73 Add a utility for running functions in parallel. 2011-07-13 13:52:48 -07:00