|
523.
|
|
|
Possible sources of error
|
|
|
type: Content of: <html><body><h2>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:277
|
|
524.
|
|
|
Deferreds greatly simplify the process of writing asynchronous code by providing a standard for registering callbacks, but there are some subtle and sometimes confusing rules that you need to follow if you are going to use them. This mostly applies to people who are writing new systems that use Deferreds internally, and not writers of applications that just add callbacks to Deferreds produced and processed by other systems. Nevertheless, it is good to know.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:279
|
|
525.
|
|
|
Firing Deferreds more than once is impossible
|
|
|
type: Content of: <html><body><h3>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:287
|
|
526.
|
|
|
Deferreds are one-shot. You can only call <code>Deferred.callback</code> or <code>Deferred.errback</code> once. The processing chain continues each time you add new callbacks to an already-called-back-to Deferred.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:289
|
|
527.
|
|
|
Synchronous callback execution
|
|
|
type: Content of: <html><body><h3>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:293
|
|
528.
|
|
|
If a Deferred already has a result available, addCallback <strong>may</strong> call the callback synchronously: that is, immediately after it's been added. In situations where callbacks modify state, it is might be desirable for the chain of processing to halt until all callbacks are added. For this, it is possible to <code>pause</code> and <code>unpause</code> a Deferred's processing chain while you are adding lots of callbacks.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:295
|
|
529.
|
|
|
Be careful when you use these methods! If you <code>pause</code> a Deferred, it is <em>your</em> responsibility to make sure that you unpause it. The function adding the callbacks must unpause a paused Deferred, it should <em>never</em> be the responsibility of the code that actually fires the callback chain by calling <code>callback</code> or <code>errback</code> as this would negate its usefulness!
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/gendefer.xhtml:302
|
|
530.
|
|
|
Using Perspective Broker
|
|
|
type: Content of: <html><body><h1>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/pb-usage.xhtml:3 howto/pb-usage.xhtml:8
|
|
531.
|
|
|
Basic Example
|
|
|
type: Content of: <html><body><h2>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/pb-usage.xhtml:10
|
|
532.
|
|
|
The first example to look at is a complete (although somewhat trivial) application. It uses <code>PBServerFactory()</code> on the server side, and <code>PBClientFactory()</code> on the client side.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/pb-usage.xhtml:12
|