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

access_log_class can't be used in handle_args of aiohttp.web.Application #3158

Closed
renanivo opened this issue Jul 24, 2018 · 2 comments
Closed
Labels

Comments

@renanivo
Copy link

Long story short

I'm setting up a project with a custom access logger. My code looks like:

# main.py
import asyncio

from aiohttp import web
from aiohttp.abc import AbstractAccessLogger


class AccessLogger(AbstractAccessLogger):

    def log(self, request, response, time):
        self.logger.info(f'{request.remote} '
                         f'"{request.method} {request.path} '
                         f'done in {time}s: {response.status}')


loop = asyncio.get_event_loop()

app = web.Application(
    loop=loop,
    handler_args={
         'access_log_class': AccessLogger,
    },
)

When I run it with gunicorn:

gunicorn main:app --bind localhost:8080 --worker-class aiohttp.worker.GunicornWebWorker

An error is raised:

TypeError: type object got multiple values for keyword argument 'access_log_class'

Turns out handler_args overrides every keyword argument of Application.make_handler(), except access_log_class.

Expected behaviour

Using access_log_class in handler_args and my given value replace the default aiohttp.helpers.AccessLogger.

Actual behaviour

TypeError: type object got multiple values for keyword argument 'access_log_class'

Steps to reproduce

Setup a file with the contents of main.py above and run it with the gunicorn command above.

Your environment

python 3.6.6

$ pip freeze
aiohttp==3.3.2
async-timeout==3.0.0
attrs==18.1.0
chardet==3.0.4
gunicorn==19.9.0
idna==2.7
idna-ssl==1.1.0
multidict==4.3.1
yarl==1.2.6
@orf
Copy link
Contributor

orf commented Sep 10, 2018

Also running into this

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants