0

i'm trying to install "mod_pywebsocket" on CentOS 5.9 32 bit, by following this guide "https://code.google.com/p/websocket-sample/wiki/HowToInstallMod_pywebsocket"

But with the command "sudo python setup.py install" i see an error:

[root@localhost src]# python setup.py install
running install
running build
running build_py
running install_lib
byte-compiling /usr/lib/python2.4/site-packages/mod_pywebsocket/mux.py to mux.pyc
  File "/usr/lib/python2.4/site-packages/mod_pywebsocket/mux.py", line 926
    finally:
          ^
SyntaxError: invalid syntax
[root@localhost src]#

Here some lines of "mux.py" file:

916   Writing data will block the worker so we need to release
                # _send_condition before writing.
                self._logger.debug('Sending inner frame: %r' % inner_frame)
                self._request.connection.write(inner_frame)
                write_position += write_length

                opcode = common.OPCODE_CONTINUATION

        except ValueError, e:
            raise BadOperationException(e)
926     finally:
            self._write_inner_frame_semaphore.release()

    def replenish_send_quota(self, send_quota):
        """Replenish send quota."""

        try:
            self._send_condition.acquire()
            if self._send_quota + send_quota > 0x7FFFFFFFFFFFFFFF:
                self._send_quota = 0
                raise LogicalChannelError(

What does it mean? What i have to do?

Ned Deily
  • 83,389
  • 16
  • 128
  • 151

1 Answers1

0

The problem is that the syntax used in mux.py does not work in Python 2.4. As noted in the current Python 2 Language Reference:

Changed in version 2.5: In previous versions of Python, try...except...finally did not work. try...except had to be nested in try...finally.

My guess is that the code here in mod_pywebsockets has changed since the HowTo was last tested with Python 2.4 on CentOS. You could look at patching the code to avoid the try...except...finally or search back through the mod_pywebsockets code repo to find an earlier version that does work with Python 2.4, or you could install and use a newer version of Python 2 (Python 2.7.5 is current) alongside the system Python 2.4.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151