Skip to content

Commit

Permalink
added @Pyro4.exposure decorator
Browse files Browse the repository at this point in the history
fixing #807
  • Loading branch information
markroxor authored Oct 7, 2016
1 parent 901105e commit abe194d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions gensim/models/lsi_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, maxsize=0):
self.workers = {}
self.callback = None # a pyro proxy to this object (unknown at init time, but will be set later)


@Pyro4.expose
def initialize(self, **model_params):
"""
`model_params` are parameters used to initialize individual workers (gets
Expand Down Expand Up @@ -87,27 +87,27 @@ def initialize(self, **model_params):
if not self.workers:
raise RuntimeError('no workers found; run some lsi_worker scripts on your machines first!')


@Pyro4.expose
def getworkers(self):
"""
Return pyro URIs of all registered workers.
"""
return [worker._pyroUri for worker in itervalues(self.workers)]


@Pyro4.expose
def getjob(self, worker_id):
logger.info("worker #%i requesting a new job" % worker_id)
job = self.jobs.get(block=True, timeout=1)
logger.info("worker #%i got a new job (%i left)" % (worker_id, self.jobs.qsize()))
return job


@Pyro4.expose
def putjob(self, job):
self._jobsreceived += 1
self.jobs.put(job, block=True, timeout=HUGE_TIMEOUT)
logger.info("added a new job (len(queue)=%i items)" % self.jobs.qsize())


@Pyro4.expose
def getstate(self):
"""
Merge projections from across all workers and return the final projection.
Expand All @@ -130,7 +130,7 @@ def getstate(self):
logger.info("sending out merged projection")
return result


@Pyro4.expose
def reset(self):
"""
Initialize all workers for a new decomposition.
Expand All @@ -142,6 +142,7 @@ def reset(self):
self._jobsdone = 0
self._jobsreceived = 0

@Pyro4.expose
@Pyro4.oneway
@utils.synchronous('lock_update')
def jobdone(self, workerid):
Expand Down

0 comments on commit abe194d

Please sign in to comment.