Edgewall Software
Modify

Opened 10 years ago

Last modified 6 months ago

#11686 new enhancement

Official support for uwsgi

Reported by: anonymous Owned by:
Priority: normal Milestone: next-stable-1.6.x
Component: web frontend Version:
Severity: normal Keywords: uwsgi
Cc: Ryan J Ollos Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When using uwsgi + refresh the site fast you get tons of:

Traceback (most recent call last):
  File "/home/trac/uwsgi-test/local/lib/python2.7/site-packages/trac/web/main.py", line 474, in dispatch_request
    return _dispatch_request(req, env, env_error)
  File "/home/trac/uwsgi-test/local/lib/python2.7/site-packages/trac/web/main.py", line 513, in _dispatch_request
    send_internal_error(env, req, sys.exc_info())
  File "/home/trac/uwsgi-test/local/lib/python2.7/site-packages/trac/web/main.py", line 630, in send_internal_error
    req.send_error(exc_info, status=500, env=env, data=data)
  File "/home/trac/uwsgi-test/local/lib/python2.7/site-packages/trac/web/api.py", line 581, in send_error
    self.write(data)
  File "/home/trac/uwsgi-test/local/lib/python2.7/site-packages/trac/web/api.py", line 660, in write
    self._write(data)
IOError: write error

I see that there is a special case for mod_wsgi, maybe you could add one for uwsgi too? http://trac.edgewall.org/browser/branches/1.0-stable/trac/web/api.py#L666

Saw that atleast jomae uses uwsgi…

Also, is there any recommended conf for uwsgi? threads - on/off? and so on…

Attachments (0)

Change History (10)

comment:1 by Ryan J Ollos, 10 years ago

Cc: Ryan J Ollos added

comment:2 by Jun Omae, 10 years ago

I quickly tried to reproduce it. But cannot reproduce. However, I think that you can try to use disable-write-exception.

Adding the case of uWSGI, patch is the following.

  • trac/web/api.py

    diff --git a/trac/web/api.py b/trac/web/api.py
    index 6777b1c..786532b 100644
    a b class Request(object):  
    661661        except (IOError, socket.error), e:
    662662            if e.args[0] in (errno.EPIPE, errno.ECONNRESET, 10053, 10054):
    663663                raise RequestDone
    664             # Note that mod_wsgi raises an IOError with only a message
    665             # if the client disconnects
     664            # Note that some wsgi containers raise an IOError with only a
     665            # message if the client disconnects
    666666            if 'mod_wsgi.version' in self.environ and \
    667667               e.args[0] in ('failed to write data',
    668668                             'client connection closed'):
    669669                raise RequestDone
     670            if 'uwsgi.version' in self.environ and e.args[0] == 'write error':
     671                raise RequestDone
    670672            raise
    671673
    672674    # Internal methods

Generally, patch is like this.

  • trac/web/api.py

    diff --git a/trac/web/api.py b/trac/web/api.py
    index 6777b1c..336b476 100644
    a b class Request(object):  
    661661        except (IOError, socket.error), e:
    662662            if e.args[0] in (errno.EPIPE, errno.ECONNRESET, 10053, 10054):
    663663                raise RequestDone
    664             # Note that mod_wsgi raises an IOError with only a message
    665             # if the client disconnects
    666             if 'mod_wsgi.version' in self.environ and \
    667                e.args[0] in ('failed to write data',
    668                              'client connection closed'):
     664            # Note that some wsgi containers raise an IOError with only a
     665            # message if the client disconnects. Normally, an IOError has both
     666            # an errno and a message.
     667            if len(e.args) == 1 and isinstance(e.args[0], basestring):
    669668                raise RequestDone
    670669            raise
    671670

comment:3 by anonymous, 10 years ago

Only thing i did was the F5 the page many times quickly, thanks for the patch!

What about threads? http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html?highlight=threads#a-note-on-python-threads

Is it something trac uses?

comment:4 by Jun Omae, 10 years ago

I don't know that. I've used uWSGI for a testing purpose only. You can ask it on the MailingList or in the IrcChannel.

comment:5 by Ryan J Ollos, 10 years ago

Milestone: next-stable-1.0.x

comment:6 by Jun Omae, 10 years ago

Component: generalweb frontend
Keywords: uwsgi added

#9973 is the same on mod_wsgi.

comment:7 by Ryan J Ollos, 9 years ago

Summary: Offical support for uwsgiOfficial support for uwsgi

comment:8 by Ryan J Ollos, 7 years ago

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:9 by Ryan J Ollos, 4 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

comment:10 by Ryan J Ollos, 6 months ago

Milestone: next-stable-1.4.xnext-stable-1.6.x

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.