Bug report
Memory leak in warnings module
Steps to reproduce:
- Create test script
`$ cat > memory_leak_warnings.py << EOF
import warnings
import random
while True:
warn_text = str(random.random())
warnings.warn(warn_text, DeprecationWarning)
EOF`
-
Run script
docker run -it --rm --name memory-leak-warnings -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3.9 python memory_leak_warnings.py
-
Monitor memory usage of container with running script
$ docker stats memory-leak-warnings
And you can see MEM USAGE constantly increased

https://docs.python.org/3/library/warnings.html
Warnings is a standard module, anyone can use it.
Having an application with a lot of dependencies - you have no idea which module use warnings module, so in production you will have memory leak.
For example aiomysql use it https://github.com/aio-libs/aiomysql/blob/master/aiomysql/cursors.py#L479 and seems like it is ok to use warnings standard module.
I have to disable warnings to get rid such kind of memory leaks. Is it ok? Or maybe warnings must be disabled on production enviroments? If so - this should be noticed in documentaion.
Thanks
Your environment
Bug report
Memory leak in warnings module
Steps to reproduce:
`$ cat > memory_leak_warnings.py << EOF
import warnings
import random
while True:
warn_text = str(random.random())
warnings.warn(warn_text, DeprecationWarning)
EOF`
Run script
docker run -it --rm --name memory-leak-warnings -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3.9 python memory_leak_warnings.pyMonitor memory usage of container with running script
$ docker stats memory-leak-warningsAnd you can see MEM USAGE constantly increased

https://docs.python.org/3/library/warnings.html
Warnings is a standard module, anyone can use it.
Having an application with a lot of dependencies - you have no idea which module use warnings module, so in production you will have memory leak.
For example aiomysql use it https://github.com/aio-libs/aiomysql/blob/master/aiomysql/cursors.py#L479 and seems like it is ok to use warnings standard module.
I have to disable warnings to get rid such kind of memory leaks. Is it ok? Or maybe warnings must be disabled on production enviroments? If so - this should be noticed in documentaion.
Thanks
Your environment