예제 #1
0
    def uimap(self, f, *args, **kwds):
        AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)

        def submit(*argz):
            """send a job to the server"""
            _pool = self._serve()
            #print("using %s local workers" % _pool.get_ncpus())
            try:
                return _pool.submit(f, argz, globals=globals())
            except pp.DestroyedServerError:
                self._is_alive(None)

        def imap_unordered(it):
            """build a unordered map iterator"""
            it = list(it)
            while len(it):
                for i, job in enumerate(it):
                    if job.finished:
                        yield it.pop(i)()
                        break
                # yield it.pop(0).get()  # wait for the first element?
                # *subprocess*           # alternately, loop in a subprocess
            return  #raise StopIteration

        # submit all jobs, then collect results as they become available
        return imap_unordered(builtins.map(submit, *args))
예제 #2
0
파일: pp.py 프로젝트: snormore/pathos
 def imap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     def submit(*argz):
         """send a job to the server"""
        #print "using", __STATE['server'].get_ncpus(), 'local workers'
         return __STATE['server'].submit(f, argz, globals=globals())
     # submit all jobs, then collect results as they become available
     return (subproc() for subproc in __builtin__.map(submit, *args))
예제 #3
0
    def imap(self, f, *args, **kwds):
        AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)

        def submit(*argz):
            """send a job to the server"""
            _pool = self._serve()
            #print "using", _pool.get_ncpus(), 'local workers'
            return _pool.submit(f, argz, globals=globals())

        # submit all jobs, then collect results as they become available
        return (subproc() for subproc in __builtin__.map(submit, *args))
예제 #4
0
 def imap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     def submit(*argz):
         """send a job to the server"""
         _pool = self._serve()
        #print "using", _pool.get_ncpus(), 'local workers'
         try:
             return _pool.submit(f, argz, globals=globals())
         except pp.DestroyedServerError:
             self._is_alive(None)
     # submit all jobs, then collect results as they become available
     return (subproc() for subproc in __builtin__.map(submit, *args))
예제 #5
0
 def imap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     def submit(*argz):
         """send a job to the server"""
         _pool = self._serve()
        #print("using %s local workers" % _pool.get_ncpus())
         try:
             return _pool.submit(f, argz, globals=globals())
         except pp.DestroyedServerError:
             self._is_alive(None)
     # submit all jobs, then collect results as they become available
     return (subproc() for subproc in list(builtins.map(submit, *args)))
예제 #6
0
 def uimap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     def submit(*argz):
         """send a job to the server"""
         _pool = self._serve()
        #print "using", _pool.get_ncpus(), 'local workers'
         try:
             return _pool.submit(f, argz, globals=globals())
         except pp.DestroyedServerError:
             self._is_alive(None)
     def imap_unordered(it):
         """build a unordered map iterator"""
         while len(it):
             for i,job in enumerate(it):
                 if job.finished:
                     yield it.pop(i)()
                     break
             # yield it.pop(0).get()  # wait for the first element?
             # *subprocess*           # alternately, loop in a subprocess
         raise StopIteration
     # submit all jobs, then collect results as they become available
     return imap_unordered(__builtin__.map(submit, *args))
예제 #7
0
 def uimap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     _pool = self._serve()
     return _pool.imap_unordered(star(f), zip(*args))  # chunksize
예제 #8
0
 def uimap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     _pool = self._serve()
     return _pool.imap_unordered(star(f), zip(*args)) # chunksize
예제 #9
0
 def uimap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     return __STATE['threads'].imap_unordered(star(f), zip(*args)) # chunksize
예제 #10
0
 def imap(self, f, *args, **kwds):
     AbstractWorkerPool._AbstractWorkerPool__imap(self, f, *args, **kwds)
     return __STATE['pool'].imap(star(f), zip(*args)) # chunksize