Index: gateway.py
===================================================================
--- gateway.py	(revision 64583)
+++ gateway.py	(working copy)
@@ -206,9 +206,13 @@
             # to inform the other side
             channel.close("execution disallowed")

-    def _servemain(self, joining=True):
-        from sys import exc_info
-        self._initreceive(requestqueue=True)
+    def _initdispatch(self):
+        self._dispatcherthread = threading.Thread(name="dispatcher",
+                                 target=self._thread_dispatcher)
+        self._dispatcherthread.setDaemon(1)
+        self._dispatcherthread.start()
+
+    def _thread_dispatcher(self):
         try:
             while 1:
                 item = self._requestqueue.get()
@@ -221,6 +225,11 @@
                     break
         finally:
             self._trace("_servemain finished")
+
+    def _servemain(self, joining=True):
+        self._requestqueue = Queue.Queue()
+        self._initdispatch()
+        self._thread_receiver()
         if joining:
             self.join()

@@ -344,9 +353,9 @@
             to stop. the joinexec parameter is obsolete.
         """
         current = threading.currentThread()
-        if self._receiverthread.isAlive():
-            self._trace("joining receiver thread")
-            self._receiverthread.join()
+        if self._dispatcherthread.isAlive():
+            self._trace("joining dispatcher thread")
+            self._dispatcherthread.join(10)

     def exit(self):
         """ Try to stop all exec and IO activity. """
