Thanks for your answer, Roberto.
You mean something like this ?

try:
   ...
except:
    from django.db import connection
    connection.close()
    return uwsgi.SPOOL_RETRY



2013/12/1 Roberto De Ioris <[email protected]>

>
> > Hi, guys.
> >
> > my server uses uwsgi 1.9.20 and django 1.6
> >
> >
> > [uwsgi]
> > base_path = /home/myproject/
> > logs_path = %(base_path)logs/
> > tmp_path = %(base_path)tmp/
> > module = server.manage_uwsgi
> > uid = www-data
> > gid = www-data
> > virtualenv = /home/myproject
> > master = true
> > vacuum = true
> > harakiri-verbose = true
> > log-x-forwarded-for = true
> > no-orphans = true
> > socket = 127.0.0.1:50051
> > socket = 127.0.0.1:50052
> > socket = 127.0.0.1:50053
> > workers = 3
> > map-socket = 0:1
> > map-socket = 1:2
> > map-socket = 2:3
> > chmod-socket = 774
> > daemonize = %(logs_path)uwsgi_daemonize.log
> > logto = %(logs_path)uwsgi_logto.log
> > memory-report = true
> > listen = 256
> > max-requests = 2000
> > reload-on-as = 1024
> > reload-on-rss = 1024
> > log-slow = true
> > harakiri = 120
> > limit-as = 1024
> > gevent = 48
> > spooler = %(tmp_path)
> >
> >
> > django databases have
> > 'CONN_MAX_AGE': 600
> >
> >
> > I use gevent to make some requests to external websites in admin panel.
> > In addition I use spooler to make internal requests like "prepare some
> big
> > .xls file in background".
> > Gevent cant be used for spooler tasks, because I had problems with django
> > blocking code style and mysql.
> >
> >
> > So, I have a problem with spooler requests. Server works fine for 1 day
> > approximately. Errors occur on the next day. I cant launch spooler
> > requests. All of them raises a "Mysql server has gone away".
>
>
> you should catch that exception in your spooler code and issue:
>
> from django.db import connection
> connection.close()
>
> this will force your database adapter to reconnect.
>
>
> If i remember correctly django-celery do this before (or after ??) each
> task
> so you may follow that approach too (without bothering with exceptions)
>
> --
> Roberto De Ioris
> http://unbit.it
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to