Title: Memory leak: warnings module · Issue #97557 · python/cpython · GitHub
Open Graph Title: Memory leak: warnings module · Issue #97557 · python/cpython
X Title: Memory leak: warnings module · Issue #97557 · python/cpython
Description: 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, DeprecationWarni...
Open Graph Description: 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()) w...
X Description: 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.ra...
Opengraph URL: https://github.com/python/cpython/issues/97557
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak: warnings module","articleBody":"# Bug report\r\n\r\nMemory leak in **warnings** module\r\nSteps to reproduce:\r\n\r\n1. Create test script\r\n`$ cat \u003e memory_leak_warnings.py \u003c\u003c EOF \r\nimport warnings\r\nimport random\r\n\r\nwhile True:\r\n warn_text = str(random.random())\r\n warnings.warn(warn_text, DeprecationWarning)\r\nEOF`\r\n\r\n2. Run script\r\n`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`\r\n\r\n3. Monitor memory usage of container with running script\r\n`$ docker stats memory-leak-warnings`\r\n\r\nAnd you can see MEM USAGE constantly increased\r\n\r\n\r\nhttps://docs.python.org/3/library/warnings.html\r\nWarnings is a standard module, anyone can use it.\r\nHaving an application with a lot of dependencies - you have no idea which module use warnings module, so in production you will have memory leak.\r\nFor 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.\r\n\r\nI 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.\r\n\r\nThanks\r\n\r\n# Your environment\r\n\r\n- CPython versions tested on: 3.6, 3.7, 3.9, 3.10\r\n- Operating system and architecture: https://hub.docker.com/_/python\r\n","author":{"url":"https://github.com/teplyakoff","@type":"Person","name":"teplyakoff"},"datePublished":"2022-09-26T08:03:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/97557/cpython/issues/97557"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb0beb7b-7aed-35fd-6cdb-5807073497d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 887E:24E3F0:13C3D2:1A7BA7:6A4D3057 |
| html-safe-nonce | 4d4cb72298aacfe5a07df6bd1f3fd0efbe5881fe6f4d606b8fbbabd6061e5249 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODdFOjI0RTNGMDoxM0MzRDI6MUE3QkE3OjZBNEQzMDU3IiwidmlzaXRvcl9pZCI6IjM1NjI3NDYyNTc5NTU2OTY3MjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a56cd68a6d264aedee013a1445d055cd61020dba6a5b142b842e39191ecb3573 |
| hovercard-subject-tag | issue:1385616777 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/97557/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c42c1c332b35ad6d6cb2a09e5ffef22a62ece914405ed4117c66291ecd53a24/python/cpython/issues/97557 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c42c1c332b35ad6d6cb2a09e5ffef22a62ece914405ed4117c66291ecd53a24/python/cpython/issues/97557 |
| og:image:alt | 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()) w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | teplyakoff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 93f17a978ee60bc4668e1d7b90e6bd2d622261fd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width