-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Consistently use Python's warnings module and remove utils.warn
#1590
Comments
|
Even better might be to get the warning into the Gunicorn log, wherever that is. We could change the two places where we do this in the pasterapp code to set |
I was thinking that warnings on stderr would usually just go nowhere, or if done well then into a log file somewhere if the service's (error) output is written anywhere; I think this would be an improvement for people who use I'm not a huge fan of it going to I think it would be better practice to configure |
All very interesting. I do not know yet what the best approach is. This is the first time I've learned about the warnings module, myself. I like using a standard mechanism for warnings. I dislike adding more CLI options. As a server, Gunicorn can be opinionated about these issues. What we do right now is a strong opinion, to always log to stderr. I think @berkerpeksag comment is correct. However, users run Our glogging module uses We could update any relevant examples to add py.warnings handlers, too, if we want to push it further. What do you all think? |
I think the kind of warnings that are put out through the The opinion I have is that people should take advantage of the warnings module for notifying/being notified about development (rather than operational) concerns. When used by developers on both sides, they are really useful - easier to maintain/filter than in depth changelogs, and again easier for broadcasting/picking up on development directions. At very least good deprecation warnings are brilliant when it comes to updating dependencies; I send them to their own log for this. I think having another logging option like |
IMO the current behaviour is the correct one if you consider it under the angle "gunicorn is a server". At this level we are more interested by the log since you don't wan't to raise anything just log that deprecation when the gunicorn daemon is upgraded (HUP/USR2) and let the op know/prepare the next upgrade that will require a full restart of gunicorn with new options. For those who embed Gunicorn inside their service the case may be different, but I would prefer to keep the current behaviour which is a common pattern among other servers too. |
For all these reasons, I propose we:
Falcon does something similar: https://github.com/falconry/falcon/blob/master/falcon/util/misc.py#L53 |
I also like Falcon's class ConfigFile(Setting):
deprecated_options = {
'msg': 'The ``spam:PATH`` format is deprecated.',
'hint': 'Please use ``python:PATH`` instead.',
'will_be_removed': '20.0',
'id': 'config.W001',
}
name = 'config'
section = 'Config File'
... I borrowed this idea from https://docs.djangoproject.com/en/1.11/topics/migrations/#considerations-when-removing-model-fields |
Marking this for R20 and let's consider it low priority / nice to have. I think we all agree our current warning to stderr is okay for now. I second @berkerpeksag comment that having a way to easily mark deprecation in the code would be great for the future. |
I suppose one way that keeps current behaviour and adds python warnings (although with non ideal filename/funcName/lineno/module/pathname in the resulting log record) is to use a wrapper that calls I would prefer it if |
@tilgovi @berkerpeksag what your current position about it? i'm temped to close it and make and finish #1482 for the next milestone . Thoughts? |
After #1957 the only use will be for |
Proposal:
|
@tilgovi i think the last thing we should now do is to remove gaiohttp, right? |
There is a
util.warn
function which prints to stderr with some fanfare which is only used to say that two pasterapp functions are deprecated in favour ongunicorn --paste $config
. These should use aDeprecationWarning
.The text was updated successfully, but these errors were encountered: