We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Lsi distributed fail
Hi, 
I've got a problem with the lsi distributed. When i executed the example:

https://radimrehurek.com/gensim/dist_lsi.html

First configure the server (enviroment variables), then i run  the server, worker and dispatcher.

And all without errros. But when i executed the code. I have this fail:
![image](https://cloud.githubusercontent.com/assets/10063469/17175207/799856c8-5406-11e6-8713-ca7ad342baf8.png)

Why does this happens? How can i solve?

Thank you in advance.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gensim/models/lsi_worker.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz>
5 # Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html
6 
7 """
8 USAGE: %(program)s
9 
10     Worker ("slave") process used in computing distributed LSI. Run this script \
11 on every node in your cluster. If you wish, you may even run it multiple times \
12 on a single machine, to make better use of multiple cores (just beware that \
13 memory footprint increases accordingly).
14 
15 Example: python -m gensim.models.lsi_worker
16 """
17 
18 
19 from __future__ import with_statement
20 import os, sys, logging
21 import threading
22 import tempfile
23 try:
24     import Queue
25 except ImportError:
26     import queue as Queue
27 import Pyro4
28 from gensim.models import lsimodel
29 from gensim import utils
30 
31 logger = logging.getLogger('gensim.models.lsi_worker')
32 
33 
34 SAVE_DEBUG = 0 # save intermediate models after every SAVE_DEBUG updates (0 for never)
35 
36 
37 
38 class Worker(object):
39     def __init__(self):
40         self.model = None
41 
42 
43     def initialize(self, myid, dispatcher, **model_params):
44         self.lock_update = threading.Lock()
45         self.jobsdone = 0 # how many jobs has this worker completed?
46         self.myid = myid # id of this worker in the dispatcher; just a convenience var for easy access/logging TODO remove?
47         self.dispatcher = dispatcher
48         self.finished = False
49         logger.info("initializing worker #%s" % myid)
50         self.model = lsimodel.LsiModel(**model_params)
51 
52 
53     @Pyro4.oneway
54     def requestjob(self):
55         """
56         Request jobs from the dispatcher, in a perpetual loop until `getstate()` is called.
57         """
58         if self.model is None:
59             raise RuntimeError("worker must be initialized before receiving jobs")
60 
61         job = None
62         while job is None and not self.finished:
63             try:
64                 job = self.dispatcher.getjob(self.myid)
65             except Queue.Empty:
66                 # no new job: try again, unless we're finished with all work
67                 continue
68         if job is not None:
69             logger.info("worker #%s received job #%i" % (self.myid, self.jobsdone))
70             self.processjob(job)
71             self.dispatcher.jobdone(self.myid)
72         else:
73             logger.info("worker #%i stopping asking for jobs" % self.myid)
74 
75 
76     @utils.synchronous('lock_update')
77     def processjob(self, job):
78         self.model.add_documents(job)
79         self.jobsdone += 1
80         if SAVE_DEBUG and self.jobsdone % SAVE_DEBUG == 0:
81             fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')
82             self.model.save(fname)
83 
84 
85     @utils.synchronous('lock_update')
86     def getstate(self):
87         logger.info("worker #%i returning its state after %s jobs" %
88                     (self.myid, self.jobsdone))
89         assert isinstance(self.model.projection, lsimodel.Projection)
90         self.finished = True
91         return self.model.projection
92 
93 
94     @utils.synchronous('lock_update')
95     def reset(self):
96         logger.info("resetting worker #%i" % self.myid)
97         self.model.projection = self.model.projection.empty_like()
98         self.finished = False
99 
100 
101     @Pyro4.oneway
102     def exit(self):
103         logger.info("terminating worker #%i" % self.myid)
104         os._exit(0)
105 #endclass Worker
106 
107 
108 
109 def main():
110     logging.basicConfig(format = '%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
111     logger.info("running %s" % " ".join(sys.argv))
112 
113     program = os.path.basename(sys.argv[0])
114     # make sure we have enough cmd line parameters
115     if len(sys.argv) < 1:
116         print(globals()["__doc__"] % locals())
117         sys.exit(1)
118 
119     utils.pyro_daemon('gensim.lsi_worker', Worker(), random_suffix=True)
120 
121     logger.info("finished running %s" % program)
122 
123 
124 
125 if __name__ == '__main__':
126     main()
127
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gensim/models/lsi_worker.py b/gensim/models/lsi_worker.py
--- a/gensim/models/lsi_worker.py
+++ b/gensim/models/lsi_worker.py
@@ -39,7 +39,7 @@
     def __init__(self):
         self.model = None
 
-
+    @Pyro4.expose
     def initialize(self, myid, dispatcher, **model_params):
         self.lock_update = threading.Lock()
         self.jobsdone = 0 # how many jobs has this worker completed?
@@ -49,7 +49,7 @@
         logger.info("initializing worker #%s" % myid)
         self.model = lsimodel.LsiModel(**model_params)
 
-
+    @Pyro4.expose
     @Pyro4.oneway
     def requestjob(self):
         """
@@ -81,7 +81,7 @@
             fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')
             self.model.save(fname)
 
-
+    @Pyro4.expose
     @utils.synchronous('lock_update')
     def getstate(self):
         logger.info("worker #%i returning its state after %s jobs" %
@@ -90,7 +90,7 @@
         self.finished = True
         return self.model.projection
 
-
+    @Pyro4.expose
     @utils.synchronous('lock_update')
     def reset(self):
         logger.info("resetting worker #%i" % self.myid)

{"golden_diff": "diff --git a/gensim/models/lsi_worker.py b/gensim/models/lsi_worker.py\n--- a/gensim/models/lsi_worker.py\n+++ b/gensim/models/lsi_worker.py\n@@ -39,7 +39,7 @@\n     def __init__(self):\n         self.model = None\n \n-\n+    @Pyro4.expose\n     def initialize(self, myid, dispatcher, **model_params):\n         self.lock_update = threading.Lock()\n         self.jobsdone = 0 # how many jobs has this worker completed?\n@@ -49,7 +49,7 @@\n         logger.info(\"initializing worker #%s\" % myid)\n         self.model = lsimodel.LsiModel(**model_params)\n \n-\n+    @Pyro4.expose\n     @Pyro4.oneway\n     def requestjob(self):\n         \"\"\"\n@@ -81,7 +81,7 @@\n             fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')\n             self.model.save(fname)\n \n-\n+    @Pyro4.expose\n     @utils.synchronous('lock_update')\n     def getstate(self):\n         logger.info(\"worker #%i returning its state after %s jobs\" %\n@@ -90,7 +90,7 @@\n         self.finished = True\n         return self.model.projection\n \n-\n+    @Pyro4.expose\n     @utils.synchronous('lock_update')\n     def reset(self):\n         logger.info(\"resetting worker #%i\" % self.myid)\n", "issue": "Lsi distributed fail\nHi, \nI've got a problem with the lsi distributed. When i executed the example:\n\nhttps://radimrehurek.com/gensim/dist_lsi.html\n\nFirst configure the server (enviroment variables), then i run  the server, worker and dispatcher.\n\nAnd all without errros. But when i executed the code. I have this fail:\n![image](https://cloud.githubusercontent.com/assets/10063469/17175207/799856c8-5406-11e6-8713-ca7ad342baf8.png)\n\nWhy does this happens? How can i solve?\n\nThank you in advance.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz>\n# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html\n\n\"\"\"\nUSAGE: %(program)s\n\n    Worker (\"slave\") process used in computing distributed LSI. Run this script \\\non every node in your cluster. If you wish, you may even run it multiple times \\\non a single machine, to make better use of multiple cores (just beware that \\\nmemory footprint increases accordingly).\n\nExample: python -m gensim.models.lsi_worker\n\"\"\"\n\n\nfrom __future__ import with_statement\nimport os, sys, logging\nimport threading\nimport tempfile\ntry:\n    import Queue\nexcept ImportError:\n    import queue as Queue\nimport Pyro4\nfrom gensim.models import lsimodel\nfrom gensim import utils\n\nlogger = logging.getLogger('gensim.models.lsi_worker')\n\n\nSAVE_DEBUG = 0 # save intermediate models after every SAVE_DEBUG updates (0 for never)\n\n\n\nclass Worker(object):\n    def __init__(self):\n        self.model = None\n\n\n    def initialize(self, myid, dispatcher, **model_params):\n        self.lock_update = threading.Lock()\n        self.jobsdone = 0 # how many jobs has this worker completed?\n        self.myid = myid # id of this worker in the dispatcher; just a convenience var for easy access/logging TODO remove?\n        self.dispatcher = dispatcher\n        self.finished = False\n        logger.info(\"initializing worker #%s\" % myid)\n        self.model = lsimodel.LsiModel(**model_params)\n\n\n    @Pyro4.oneway\n    def requestjob(self):\n        \"\"\"\n        Request jobs from the dispatcher, in a perpetual loop until `getstate()` is called.\n        \"\"\"\n        if self.model is None:\n            raise RuntimeError(\"worker must be initialized before receiving jobs\")\n\n        job = None\n        while job is None and not self.finished:\n            try:\n                job = self.dispatcher.getjob(self.myid)\n            except Queue.Empty:\n                # no new job: try again, unless we're finished with all work\n                continue\n        if job is not None:\n            logger.info(\"worker #%s received job #%i\" % (self.myid, self.jobsdone))\n            self.processjob(job)\n            self.dispatcher.jobdone(self.myid)\n        else:\n            logger.info(\"worker #%i stopping asking for jobs\" % self.myid)\n\n\n    @utils.synchronous('lock_update')\n    def processjob(self, job):\n        self.model.add_documents(job)\n        self.jobsdone += 1\n        if SAVE_DEBUG and self.jobsdone % SAVE_DEBUG == 0:\n            fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')\n            self.model.save(fname)\n\n\n    @utils.synchronous('lock_update')\n    def getstate(self):\n        logger.info(\"worker #%i returning its state after %s jobs\" %\n                    (self.myid, self.jobsdone))\n        assert isinstance(self.model.projection, lsimodel.Projection)\n        self.finished = True\n        return self.model.projection\n\n\n    @utils.synchronous('lock_update')\n    def reset(self):\n        logger.info(\"resetting worker #%i\" % self.myid)\n        self.model.projection = self.model.projection.empty_like()\n        self.finished = False\n\n\n    @Pyro4.oneway\n    def exit(self):\n        logger.info(\"terminating worker #%i\" % self.myid)\n        os._exit(0)\n#endclass Worker\n\n\n\ndef main():\n    logging.basicConfig(format = '%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)\n    logger.info(\"running %s\" % \" \".join(sys.argv))\n\n    program = os.path.basename(sys.argv[0])\n    # make sure we have enough cmd line parameters\n    if len(sys.argv) < 1:\n        print(globals()[\"__doc__\"] % locals())\n        sys.exit(1)\n\n    utils.pyro_daemon('gensim.lsi_worker', Worker(), random_suffix=True)\n\n    logger.info(\"finished running %s\" % program)\n\n\n\nif __name__ == '__main__':\n    main()\n", "path": "gensim/models/lsi_worker.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz>\n# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html\n\n\"\"\"\nUSAGE: %(program)s\n\n    Worker (\"slave\") process used in computing distributed LSI. Run this script \\\non every node in your cluster. If you wish, you may even run it multiple times \\\non a single machine, to make better use of multiple cores (just beware that \\\nmemory footprint increases accordingly).\n\nExample: python -m gensim.models.lsi_worker\n\"\"\"\n\n\nfrom __future__ import with_statement\nimport os, sys, logging\nimport threading\nimport tempfile\ntry:\n    import Queue\nexcept ImportError:\n    import queue as Queue\nimport Pyro4\nfrom gensim.models import lsimodel\nfrom gensim import utils\n\nlogger = logging.getLogger('gensim.models.lsi_worker')\n\n\nSAVE_DEBUG = 0 # save intermediate models after every SAVE_DEBUG updates (0 for never)\n\n\n\nclass Worker(object):\n    def __init__(self):\n        self.model = None\n\n    @Pyro4.expose\n    def initialize(self, myid, dispatcher, **model_params):\n        self.lock_update = threading.Lock()\n        self.jobsdone = 0 # how many jobs has this worker completed?\n        self.myid = myid # id of this worker in the dispatcher; just a convenience var for easy access/logging TODO remove?\n        self.dispatcher = dispatcher\n        self.finished = False\n        logger.info(\"initializing worker #%s\" % myid)\n        self.model = lsimodel.LsiModel(**model_params)\n\n    @Pyro4.expose\n    @Pyro4.oneway\n    def requestjob(self):\n        \"\"\"\n        Request jobs from the dispatcher, in a perpetual loop until `getstate()` is called.\n        \"\"\"\n        if self.model is None:\n            raise RuntimeError(\"worker must be initialized before receiving jobs\")\n\n        job = None\n        while job is None and not self.finished:\n            try:\n                job = self.dispatcher.getjob(self.myid)\n            except Queue.Empty:\n                # no new job: try again, unless we're finished with all work\n                continue\n        if job is not None:\n            logger.info(\"worker #%s received job #%i\" % (self.myid, self.jobsdone))\n            self.processjob(job)\n            self.dispatcher.jobdone(self.myid)\n        else:\n            logger.info(\"worker #%i stopping asking for jobs\" % self.myid)\n\n\n    @utils.synchronous('lock_update')\n    def processjob(self, job):\n        self.model.add_documents(job)\n        self.jobsdone += 1\n        if SAVE_DEBUG and self.jobsdone % SAVE_DEBUG == 0:\n            fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')\n            self.model.save(fname)\n\n    @Pyro4.expose\n    @utils.synchronous('lock_update')\n    def getstate(self):\n        logger.info(\"worker #%i returning its state after %s jobs\" %\n                    (self.myid, self.jobsdone))\n        assert isinstance(self.model.projection, lsimodel.Projection)\n        self.finished = True\n        return self.model.projection\n\n    @Pyro4.expose\n    @utils.synchronous('lock_update')\n    def reset(self):\n        logger.info(\"resetting worker #%i\" % self.myid)\n        self.model.projection = self.model.projection.empty_like()\n        self.finished = False\n\n\n    @Pyro4.oneway\n    def exit(self):\n        logger.info(\"terminating worker #%i\" % self.myid)\n        os._exit(0)\n#endclass Worker\n\n\n\ndef main():\n    logging.basicConfig(format = '%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)\n    logger.info(\"running %s\" % \" \".join(sys.argv))\n\n    program = os.path.basename(sys.argv[0])\n    # make sure we have enough cmd line parameters\n    if len(sys.argv) < 1:\n        print(globals()[\"__doc__\"] % locals())\n        sys.exit(1)\n\n    utils.pyro_daemon('gensim.lsi_worker', Worker(), random_suffix=True)\n\n    logger.info(\"finished running %s\" % program)\n\n\n\nif __name__ == '__main__':\n    main()\n", "path": "gensim/models/lsi_worker.py"}]}