[Twisted-Python] newbie: groking flows

Nesbitt, Steve snesbitt at cobaltgroup.com
Wed Oct 8 20:21:02 MDT 2003


All:

I'm trying to grok flows in general and how to mix cooperative and blocking
flows in particular. I've been reviewing the documentation and have a better
understanding, but something is still eluding me. I'm hoping someone can
help me out with either some pseudocode (or a real world example)

Here's my design problem:
When I start the server, I generate a series of lookup table objects (called
"registries") by parsing through a series of XML files. XML-RPC requests
come in requesting information and these registries are then used to help
fulfill the request. Periodically, albeit infrequently, one of the original
source XML files may change and an XML-RPC call will request that the
registries be updated/regenerated. During the regeneration process, which
can take multiple seconds, all lookup and additional regeneration requests
should block until completion of the regeneration. Once completed, blocked
requests should resume.

Based on my reading I think this is what should do:
1) Periodically during a lookup call a flow.Cooperate event to allow other
lookup events from other requests to be handled.

2) To avoid a regeneration event in the midst of a lookup, I should make
sure that a flow.Cooperate event is *not* issued at any time during a
critical part of the lookup process ( In other words one can consider the
code executed between two flow.Cooperate statements as a transaction)

3) When I start a regeneration event I should wrap the regeneration method
in a flow.Block controller.


So here are some specific questions:
1) Is my basic understanding correct? In particular am I guaranteed correct
behavior using the above outline?

2) Am I correct in believing that wrapping a method in flow.Block actually
executes the method? That is, the statement flow.Block( foo( bar ) )
   executes foo.bar immediately?

3) How do I access the results of flow.Block( foo( bar ) )? In particular
how do I see the return result or any exceptions tr\hrown by foo?

4) Am I correct in believing that while flow.Block( foo(bar) ) is executing
any incoming requests will be prevented from executing?

5) Is it possible to defer a blocking method? This covers the scenario where
two regeneration events occur within the same time frame.


Thanks in advance for the help and sorry for the length of the post. I'll be
glad to write thisx up as a how to if that would be helpful.


Thanks in advance for the help.

-steve

Stephen Nesbitt
Senior Configuration Management Engineer
The Cobalt Group
snesbitt at cobaltgroup.com






This e-mail transmission contains information intended only for the use of
the recipient(s) named above. Further, it contains information that may be
privileged and confidential. If you are not the intended recipient, you are
hereby notified that any dissemination, distribution, or copying of this
message (including any attachments) is strictly prohibited. If you have
received this e-mail in error, please notify the sender by reply e-mail and
then delete this message from your mail system. Thank you for your
compliance.




More information about the Twisted-Python mailing list