Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server not able to get address raising no attribute 'cfg_addr' #199

Open
shuoli84 opened this issue Aug 29, 2014 · 7 comments · May be fixed by #200
Open

Server not able to get address raising no attribute 'cfg_addr' #199

shuoli84 opened this issue Aug 29, 2014 · 7 comments · May be fixed by #200

Comments

@shuoli84
Copy link

My setup:

Gunicorn + gevent_socketio + django

Started the server by:

gunicorn --env DJANGO_SETTINGS_MODULE=linbang.settings -c gunicorn_config.py --error-logfile -  linbang.wsgi:application

In gunicorn_config.py:

bind = '0.0.0.0:8000'
max_requests = 10000
worker_class = 'socketio.sgunicorn.GeventSocketIOWorker'
workers = 5

def post_fork(server, worker):
import pymysql
pymysql.install_as_MySQLdb()

 [2014-08-29 11:19:13 +0800] [79204] [ERROR] Exception in worker process:
  Traceback (most recent call last):
    File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
    super(GeventWorker, self).init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
    self.run()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/sgunicorn.py", line 80, in run
    **ssl_args
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/server.py", line 72, in __init__
    address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'
Traceback (most recent call last):
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
    super(GeventWorker, self).init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
    self.run()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/sgunicorn.py", line 80, in run
    **ssl_args
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/server.py", line 72, in __init__
    address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'
@shuoli84 shuoli84 linked a pull request Aug 29, 2014 that will close this issue
@mateuszf
Copy link

I'm having the same issue when stress testing simple test app.

AttributeError: 'socket' object has no attribute 'cfg_addr'

@shuoli84
I see that you use workers = 5 in your config file.
Does it work without problems ? I was having errors when workers was set to > 1, despite the fact that I was using websocket transport (so this wasn't issue of long-polling and different processes for each request).

@Jakobovski
Copy link

I am having the same issue.

@ant9000
Copy link

ant9000 commented Mar 30, 2015

Save the following snippet as geventworker.py

from socketio.sgunicorn import GeventSocketIOWorker

class MyGeventSocketIOWorker(GeventSocketIOWorker):
    policy_server = False

and launch your app with

 gunicorn --worker-class geventworker.MyGeventSocketIOWorker wsgy:app

@jaredmcqueen
Copy link

as noted here, using earlier gunicorn versions may work for you.

pip uninstall gunicorn
pip install gunicorn==18.0

@jares777
Copy link

I just committed a fix, which will make it work with newer version of gunicorn. The merge is pending.
ant9000 workaround will help but better solution is to adapt to gunicorn changes.

@arnuschky
Copy link
Contributor

Merge will stay pending forever as this project is missing a maintainer.

BTW, I can confirm that the workaround of @ant9000 works fine. Alternatively, you can also set the environment variable POLICY_SERVER to false.

@jares777
Copy link

Cool. I will stay with my forked branch then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants