<tfoot id='2cmPM'></tfoot>
<i id='2cmPM'><tr id='2cmPM'><dt id='2cmPM'><q id='2cmPM'><span id='2cmPM'><b id='2cmPM'><form id='2cmPM'><ins id='2cmPM'></ins><ul id='2cmPM'></ul><sub id='2cmPM'></sub></form><legend id='2cmPM'></legend><bdo id='2cmPM'><pre id='2cmPM'><center id='2cmPM'></center></pre></bdo></b><th id='2cmPM'></th></span></q></dt></tr></i><div id='2cmPM'><tfoot id='2cmPM'></tfoot><dl id='2cmPM'><fieldset id='2cmPM'></fieldset></dl></div>
  • <small id='2cmPM'></small><noframes id='2cmPM'>

      <legend id='2cmPM'><style id='2cmPM'><dir id='2cmPM'><q id='2cmPM'></q></dir></style></legend>
        • <bdo id='2cmPM'></bdo><ul id='2cmPM'></ul>

        Kivy:错误弱引用对象(在时钟函数中)不再存在

        时间:2023-09-01
            <tbody id='z2hbq'></tbody>

          1. <legend id='z2hbq'><style id='z2hbq'><dir id='z2hbq'><q id='z2hbq'></q></dir></style></legend>

            <tfoot id='z2hbq'></tfoot>
            • <bdo id='z2hbq'></bdo><ul id='z2hbq'></ul>
                  <i id='z2hbq'><tr id='z2hbq'><dt id='z2hbq'><q id='z2hbq'><span id='z2hbq'><b id='z2hbq'><form id='z2hbq'><ins id='z2hbq'></ins><ul id='z2hbq'></ul><sub id='z2hbq'></sub></form><legend id='z2hbq'></legend><bdo id='z2hbq'><pre id='z2hbq'><center id='z2hbq'></center></pre></bdo></b><th id='z2hbq'></th></span></q></dt></tr></i><div id='z2hbq'><tfoot id='z2hbq'></tfoot><dl id='z2hbq'><fieldset id='z2hbq'></fieldset></dl></div>
                • <small id='z2hbq'></small><noframes id='z2hbq'>

                • 本文介绍了Kivy:错误弱引用对象(在时钟函数中)不再存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的错误代码我认为这个错误有什么难的地方,我在论坛上找过,但没有找到.

                  So here is my error code I think there's something hard in this error, i looked on forums but couldn't find out.

                  而且...我的手机出现错误(使用 kivy启动器 python 3 以及当我使用 buildozer 构建时)但不在我的计算机上(ubuntu 18.0.4 和 windows 10)据我了解,该错误来自删除引用的垃圾收集器,并且代码尝试在垃圾收集器之后访问引用.但我不确定我是否理解垃圾收集器的事情

                  And ... i have the error on my phone (with kivy launcher python 3 and when i build with buildozer) but not on my computer (ubuntu 18.0.4 and windows 10) The error, from what i understand, comes from the garbage collector that delete a reference and the code try to access the reference after the garbage collector. but i am not sure if I rly understand the garbage collector thing

                  我尝试了什么:

                  • 制作强引用",以便 gc 不会将其删除:
                      id: id.__self__
                  

                  在我的 kv 文件中

                  • 使用以下方法进行强引用":
                       self.refs = [
                                  self.id.__self__,
                                  self.id.__self__]
                  

                  -使用ErrorHandler来处理错误,但错误总是会出现

                  -Use the ErrorHandler to handle the error but the error keep coming for ever

                  我认为是什么导致了错误,但我不知道如何解决它:

                  • 我用来向服务器发送请求的时钟,但我不知道为什么(self.requestClient 是一个发送请求的函数):

                  • the clock I use to send request to the server but i don't know why (self.requestClient is a function to send a request) :

                  C = Clock.schedule_interval(self.requestClient, 5)

                  C = Clock.schedule_interval(self.requestClient, 5)

                  此信息在 kivy 时钟文档 :

                  重要

                  回调是弱引用的:你负责保持一个引用您的原始对象/回调.如果你不保留一个参考,ClockBase 永远不会执行你的回调

                  The callback is weak-referenced: you are responsible for keeping a reference to your original object/callback. If you don’t keep a reference, the ClockBase will never execute your callback

                  错误:

                  [ERROR  ] Exception catched by ExceptionHandler
                  05-07 11:27:45.694  2788  2823 I python  : Traceback (most recent call last):
                  05-07 11:27:45.694  2788  2823 I python  :   File path/kivy-launcher/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/launcher/kivy/core/window/window_sdl2.py", line 747, in mainloop
                  05-07 11:27:45.694  2788  2823 I python  :   File "/path/kivy-launcher/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/launcher/kivy/core/window/window_sdl2.py", line 479, in _mainloop
                  05-07 11:27:45.694  2788  2823 I python  :   File "/path/kivy-launcher/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/launcher/kivy/base.py", line 339, in idle
                  05-07 11:27:45.694  2788  2823 I python  :   File "/path/kivy-launcher/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/launcher/kivy/clock.py", line 591, in tick
                  05-07 11:27:45.694  2788  2823 I python  :   File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
                  05-07 11:27:45.694  2788  2823 I python  :   File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
                  05-07 11:27:45.694  2788  2823 I python  :   File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
                  05-07 11:27:45.694  2788  2823 I python  :   File "kivy/_clock.pyx", line 154, in kivy._clock.ClockEvent.tick
                  05-07 11:27:45.694  2788  2823 I python  :   File "kivy/_clock.pyx", line 86, in kivy._clock.ClockEvent.get_callback
                  05-07 11:27:45.694  2788  2823 I python  :   File "/path/kivy-launcher/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/launcher/kivy/weakmethod.py", line 56, in is_dead
                  05-07 11:27:45.694  2788  2823 I python  : ReferenceError: weakly-referenced object no longer exists
                  

                  感谢阅读!

                  推荐答案

                  官方文档(Kv 语言编程指南) 说要在 KV 代码中添加诸如 id_name: id_name.__self__ 之类的强"引用,但不清楚这在哪里是必要的.更重要的是,它并没有为我解决 ReferenceError:weakly-referenced object no longer exists 错误.

                  The official documentation (Kv language Programming Guide) says to add 'strong' references such as id_name: id_name.__self__ in the KV code, but it is unclear where this is necessary. What's more, it did not solve the ReferenceError: weakly-referenced object no longer exists errors for me.

                  所做 的工作是通过将其添加到 buildozer.spec 文件的 requirements 行来强制 Buildozer 使用特定版本的 hostpython3:

                  What did work is forcing Buildozer to use a specific version of hostpython3 by adding this to the requirements line of the buildozer.spec file:

                  python3==3.7.5, hostpython3==3.7.5
                  

                  还有一点需要注意:在将上述内容添加到 requirements 之后,我返回并删除了所有 __self__ 引用,它仍然可以正常工作,因此显然不再需要这些引用在 Kivy KV 语言中.

                  One more note: after adding the above to requirements, I went back and removed all my __self__ references and it still worked fine, so apparently these are no longer needed in Kivy KV language.

                  这要归功于 leo10011 的精彩回答.

                  2020-05-19 更新:这个错误 据报道已在 Kivy 2.0 中修复.

                  这篇关于Kivy:错误弱引用对象(在时钟函数中)不再存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在Android中保持kivy服务在后台运行(切换到其 下一篇:在带有 buildozer 的 android 上使用 python3

                  相关文章

                  最新文章

                  • <bdo id='umixA'></bdo><ul id='umixA'></ul>
                  <legend id='umixA'><style id='umixA'><dir id='umixA'><q id='umixA'></q></dir></style></legend>

                      <small id='umixA'></small><noframes id='umixA'>

                    1. <tfoot id='umixA'></tfoot>
                    2. <i id='umixA'><tr id='umixA'><dt id='umixA'><q id='umixA'><span id='umixA'><b id='umixA'><form id='umixA'><ins id='umixA'></ins><ul id='umixA'></ul><sub id='umixA'></sub></form><legend id='umixA'></legend><bdo id='umixA'><pre id='umixA'><center id='umixA'></center></pre></bdo></b><th id='umixA'></th></span></q></dt></tr></i><div id='umixA'><tfoot id='umixA'></tfoot><dl id='umixA'><fieldset id='umixA'></fieldset></dl></div>