1

We have a Django app that invokes a third party library. It works fine when running with runserver, but under apache + wsgi, it throws this error:

'mod_wsgi.Log' object has no attribute 'name'

I'm going to start going through the code of that library to review its logging, but my first pass didn't reveal anything particularly different than what we're doing in the main app. If anyone has any ideas or pointers, it would help a lot.

1 Answer 1

2

The code expecting a 'name' attribute to exist is wrong. The Python documentation says about the 'name' attribute:

"""name - If the file object was created using open(), the name of the file. Otherwise, some string that indicates the source of the file object, of the form "<...>". This is a read-only attribute and may not be present on all file-like objects."""

In other words, it is not required to be present.

The mod_wsgi.Log object, which is standing in as a file object for sys.stdout and sys.stderr, therefore doesn't need to have a 'name' attribute.

As such, any code which is looking for 'name' attribute has to be tolerant of it not existing.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent. This was helpful. Turns out we're logging to syslog, so the library was expecting a name on an object that didn't have a name -- just like you say.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.