FrontPage
»
ScenarioList
»
SynchronousCall
Multiplexed Zope RPC
Scenario: Synchronous Call
Assumptions
- Calling thread wants to send a message to the server and await its reply, synchronously.
- The server may send asynchronous messages directed to the calling thread; these messages must be handled by that thread.
Procedure
- Client thread invokes the ZRPC object, passing the method name as the first of a set of arbitrary arguments.
- ZRPC finds/creates a ThreadMessageHandler? corresponding to the current thread ID, and delegates the invocation to it.
- The handler marshals its threadID and the passed arguments into a message, and calls back up to the ZRPC object to put the message on the wire.
- Handler drops into "consumer mode" on its message queue, processing "out-of-band" messages while waiting for a response or exception message.
- Meanwhile, the asyncore loop is pushing inbound messages to the ZRPC object, which unpacks the threadID from the message and dispatches it to the corresponding handler, in "producer" mode.
- The "blocked-in-synchronous call" handler finally receives a
reply:
- if it is a normal return, the handler unmarshals the value, if any, and returns it.
- otherwise, the handler unmarshals the exception and raises it.