[Twisted-Python] Flow: better synchronous exceptions [patch]

Clark C. Evans cce at clarkevans.com
Tue Jun 24 01:42:39 EDT 2003

Thank you for applying this patch, it is a big improvement.
Also, to summarize our IRC chat:

  1.  You think it is about time to move flow into twisted and
      Glyph/Itamar support this move; great.

  2.  You like the idea of adding it as a top level, 
      twisted.flow.* module; this means breaking flow.py 
      into several chunks.

  3.  For the public stages and controllers, flow.py could be broken
      down into the facility that they use: twisted.flow.thread, 

  4.  The core of flow, 'wrap' function and its private stages, could
      be put into flow/flow.py; it is a bit redundant, but we could
      not think of another option.

  5.  We didn't discuss where the abstract interfaces, "Stage", and
      "Callback" should go.   Perhaps flow.interface?

  6.  We didn't discuss other public stages that are not directly
      associated with a facility, such as Zip.  Perhaps these could
      be put into flow.misc or flow.tools?

  7.  Most importantly (for me), due to the redundancy of flow/flow.py
      I'd like to ask glyph if a limited form of __init__.py import
      could be used in the case of a module/module.py mechansim so
      that the public objects in module.py could be imported into the
      module itself.    ie, in flow/__init__.py having:

         "from flow import wrap, Cooperate"

Thank you so much.


On Mon, Jun 23, 2003 at 10:46:21PM -0400, Christopher Armstrong wrote:
| Here's a patch that changes semantics of Stage.next. Currently,
| if a Deferred errbacks with an exception that you haven't 
| explicitly trapped, Stage.next will raise the Failure object
| (via the failure's trap method). I've changed this so it rather
| does `raise type(failure.value), failure.value, failure.tb'.
| What this means is that you can write code like this:
|     d = flow.wrap(getDeferred())
|     yield d
|     try:
|         result = d.next()
|     except ParticularError, e:
|         traceback.print_exc()

More information about the Twisted-Python mailing list