简体   繁体   English

“RuntimeWarning: Enable tracemalloc to get the object allocation traceback”是什么意思? 我知道如何修复,寻找意义

[英]What does "RuntimeWarning: Enable tracemalloc to get the object allocation traceback" mean? I know how to fix, looking for the meaning

When I call a coroutine without awaiting, in addition to a message warning me I have not awaited the coroutine, I also get the following warning message:当我在没有等待的情况下调用协程时,除了警告我没有等待协程的消息外,我还会收到以下警告消息:

RuntimeWarning: Enable tracemalloc to get the object allocation traceback

I know how to fix this ie by awaiting the coroutine (and I do see a lot of questions about this warning, but all the answers are how to fix it; my goal is to understand it; please don't mark my question as duplicate if possible:) );我知道如何通过等待协程来解决这个问题(我确实看到了很多关于这个警告的问题,但所有的答案都是如何解决它;我的目标是理解它;请不要将我的问题标记为重复如果可能的话:) ); in particular, what I'd really like to understand is:特别是,我真正想了解的是:

  • What is tracemalloc?什么是tracemalloc? How do I enable it?如何启用它?
  • What is the object allocation traceback?什么是 object 分配回溯?
  • How is it related to coroutines?它与协程有什么关系? and, in particular并且,特别是
  • Why is there a warning suggesting to enable tracemalloc when I don't await a coroutine?当我不等待协程时,为什么会出现提示启用 tracemalloc 的警告?

My goal in asking this is understanding the details and inner-workings of asyncio better.我提出这个问题的目的是更好地理解 asyncio 的细节和内部工作原理。

  • What is tracemalloc?什么是tracemalloc? How do I enable it?如何启用它?

tracemalloc is a module that is used to debug memory allocation in python tracemalloc 是一个用于调试 python 中 memory 分配的模块

you can enable it by setting PYTHONTRACEMALLOC environment variable to 1您可以通过将 PYTHONTRACEMALLOC 环境变量设置为 1 来启用它

check the docs for more info Tracemalloc docs检查文档以获取更多信息Tracemalloc 文档

  • What is the object allocation traceback object分配回溯是什么

It's a way how python manages memory and allocates memory for it's objects这是 python 管理 memory 并为其对象分配 memory 的一种方式

  • Why is there a warning suggesting to enable tracemalloc when I don't await a coroutine?当我不等待协程时,为什么会出现提示启用 tracemalloc 的警告?

I guess this is because memory is allocated and never used properly so we get loss of resources ie memory leak我猜这是因为 memory 已分配且从未正确使用,因此我们会丢失资源,即 memory 泄漏

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 RuntimeWarning:启用 tracemalloc 以获取 object 分配回溯错误 - How to fix RuntimeWarning: Enable tracemalloc to get the object allocation traceback error RuntimeWarning:启用tracemalloc以获取对象分配回溯 - RuntimeWarning: Enable tracemalloc to get the object allocation traceback 使用tornado.httpclient.AsyncHTTPClient时,如何修复“RuntimeWarning:启用tracemalloc以获取对象分配回溯”? - How to fix “RuntimeWarning: Enable tracemalloc to get the object allocation traceback” when using tornado.httpclient.AsyncHTTPClient? RuntimeWarning:启用 tracemalloc 以使用 asyncio.sleep 获取对象分配回溯 - RuntimeWarning: Enable tracemalloc to get the object allocation traceback with asyncio.sleep 为什么我会收到 RuntimeWarning: Enable tracemalloc to get the object allocation traceback from asyncio.run? - Why am i getting RuntimeWarning: Enable tracemalloc to get the object allocation traceback from asyncio.run? discord.py, RuntimeWarning: 启用 tracemalloc 以获取发送消息时的对象分配回溯 - discord.py, RuntimeWarning: Enable tracemalloc to get the object allocation traceback on sending message 启用 tracemalloc 以获取 object 分配回溯 PYTHON - Enable tracemalloc to get the object allocation traceback PYTHON Python Selenium - ResourceWarning:启用 tracemalloc 以获取对象分配回溯 - Python Selenium - ResourceWarning: Enable tracemalloc to get the object allocation traceback 空回溯是什么意思? - What does a null traceback mean? 这是什么意思,我该如何解决? - What does this mean and how can I fix it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM