Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-2774

Greenlet cannot bind in python 2.7

    XMLWordPrintable

    Details

      Description

      Hi,
      I am having a problem using an SSL wrapped socket in eventlet. I used the example in the documentation, by setting my own certificates. This works well with python 2.6.6. How ever for some reason I can't work with 2.7.
      Here is my piece of code
      from eventlet.green.OpenSSL import SSL
      context = SSL.Context(SSL.SSLv23_METHOD)
      context.use_certificate_file('ecert.pem'
      context.use_privatekey_file('esam.pem'
      context.set_verify(SSL.VERIFY_NONE, lambda *x: True)

      create underlying green socket and wrap it in ssl

      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
      connection = SSL.Connection(context, sock)

      configure as server

      connection.set_accept_state()
      connection.bind(('', 9090))
      connection.listen(50)

      Here is the traceback from python 2.7
      Traceback (most recent call last):
      File "engine.py", line 1152, in <module>
      connection.bind(('', 9090))
      File "/usr/lib/python2.7/site-packages/eventlet/greenio.py", line 145, in getattr
      attr = getattr(self.fd, name)
      AttributeError: 'GreenSocket' object has no attribute 'bind'

      Oopss guys my mistake.
      import socket was missing in my code

      Samuel Sekiwere

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            legacy-bitbucket-user Legacy Bitbucket Cloud User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: