Commits

bb b...@gmx.de  committed 891ee5b Draft

fixed detection of condition in which there are no websockets left

  • Participants
  • Parent commits 23907ae

Comments (0)

Files changed (1)

File araldo/app.py

 import logging
 import re
 from geventwebsocket.exceptions import WebSocketError
+from geventwebsocket.websocket import WebSocket
 import gevent
 from araldo.message import Message
 from araldo.plugins import PluginManager
 
             :param environ: environment passed by WSGIServer
         """
-        self._logger.debug("Received WebSocket call: %s" % environ)
+        #self._logger.debug("Received WebSocket call: %s" % environ)
         web_socket = environ["wsgi.websocket"]
         self._logger.debug("Adding websocket '%s'" % web_socket_name)
-        self._logger.debug("### %s" % dir(web_socket))
+        #self._logger.debug("### %s" % web_socket.__class__)
         self._websockets[web_socket_name] = web_socket
         while True:
             try:
             except gevent.Timeout, error:
                 self._logger.debug(str(error))
             gevent.sleep(0)
-            if len(self._websockets) == 0:
+            w = self._websockets
+            self._logger.debug("Current outbound: %s" % str(w))
+            if len([x for x in w if isinstance(w[x], WebSocket)]) == 0:
                 self._logger.debug(
                     "No more sockets; terminating websocket handler")
                 break