multiprocessing callbacks?

Discussion in 'Python' started by Pete Hunt, Dec 15, 2009.

  1. Pete Hunt

    Pete Hunt Guest

    Hey, everyone -

    I'm trying to use multiprocessing to create a process pool similar to
    multiprocessing.Pool, except that it works across multiple hosts. For
    various reasons, I would like the result of async_apply() to return a
    Twisted Deferred object.

    My first attempt at the implementation is:

    class DeferredProxy(managers.BaseProxy):
    _exposed_ = ("callback","errback","addCallback","addErrback")
    def callback(self, v):
    return self._callmethod("callback",(v,))

    def errback(self, v):
    return self._callmethod("errback",(v,))

    def addCallback(self, cb):
    return self._callmethod("addCallback",(cb,))

    def addErrback(self, eb):
    return self.__callmethod("adderrback",(eb,))

    class DispatchManager(managers.BaseManager):
    pass
    DispatchManager.register("Deferred", defer.Deferred, DeferredProxy)

    This, however, fails, because "cb" and "eb" cannot be pickled. I don't
    actually need to pickle them, though, because I want them to run on
    the machine on which they were created. Is there a way, in
    multiprocessing, that I can pass some sort of "callback" around that
    serves as a proxy to a remote function?

    Thanks in advance,

    Pete
     
    Pete Hunt, Dec 15, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Tam

    Client Side Callbacks for ASP.NET 1.x

    Lucas Tam, Feb 1, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    1,350
    Jeff @ Dart
    Feb 7, 2005
  2. =?Utf-8?B?TmV2ZXJseW4=?=

    Problem using Client Side Callbacks in 2.0

    =?Utf-8?B?TmV2ZXJseW4=?=, May 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    375
    =?Utf-8?B?TmV2ZXJseW4=?=
    May 8, 2005
  3. ck388
    Replies:
    1
    Views:
    10,744
    Brock Allen
    Jun 6, 2005
  4. =?Utf-8?B?RGlmZmlkZW50?=

    Callbacks and FireFox browser

    =?Utf-8?B?RGlmZmlkZW50?=, Jul 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    340
    =?Utf-8?B?RGlmZmlkZW50?=
    Jul 28, 2005
  5. =?Utf-8?B?UGF1bCBN?=

    Callbacks 2.0 and ActiveX

    =?Utf-8?B?UGF1bCBN?=, Oct 25, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    558
    sp3d2orbit
    Oct 25, 2005
Loading...

Share This Page