[Twisted-Python] (UPDATE) Suspending a result
Uwe C. Schroeder
uwe at oss4u.com
Sat Sep 13 13:58:57 EDT 2003
I forgot to mention: This is on the server side only. So both caller and
called are on one peer. The caller itself is called by another peer (and
returns a defered to the remote side)
On Saturday 13 September 2003 10:27 am, Uwe C. Schroeder wrote:
> maybe I'm sitting on my brains here, but anyways:
> I have a (possibly) blocking function. The core work of it is handled in a
> separate thread, so the blocking is not a problem for Twisted.
> However - I need to get rid of the deferred callbacks. So basically what
> I'm trying to do is to have a class/method that wraps the blocking code
> WITHOUT returning a deferred. Instead I'd like to "suspend" the return,
> certainly without blocking twisted. So here is some "pseudocode" to clarify
> what I want to do:
> # the blocking function itself
> def possibly_blocking(params):
> do something blocking
> Normally I would call this by
> which may or may not block due to what's inside the function.
> In 99% of the time it will return a result quite quickly, so no blocking.
> BUT what if. So I want to make the
> call "wait" for the result, without a deferred coming back. So I'd have to
> wrap that up somehow, so that the call seems to be waiting, but in what is
> called returning the result is delayed.
> I think one might be able to accomplish this with some kind of class that
> wraps the call and checks for the resultset once in a while, and when the
> result is there it returns the result.
> It's pretty similar to the way GUI's handle modal dialogs. The original
> modal dialog call will never return, until the dialog is closed, however
> the rest of the gui doesn't block, since internally scheduling still goes
> on. So can one wrap a "call / deferred / result" chain and block the
> caller, without blocking twisted completely ?
> Any help would be appreciated.
> (BTW: I don't want to use deferreds as the original resultset, since that
> would mean having to write tremendous state machines just to retain the
> order of the results depending on each other)
> Open Source Solutions 4U, LLC 2570 Fleetwood Drive
> Phone: +1 650 872 2425 San Bruno, CA 94066
> Cell: +1 650 302 2405 United States
> Fax: +1 650 872 2417
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
More information about the Twisted-Python