title: Kivy : Error weakly-referenced object (in a clock function) no longer exists
body: <p>So here is my error code
  I think there's something hard in this error, i looked on forums but couldn't find out.</p>
  
  <p>And ... i have the error <strong>on my phone</strong> (with <a href="https://github.com/kivy/kivy-launcher" rel="nofollow noreferrer">kivy launcher python 3</a> and when i build with buildozer) <strong>but not on my computer</strong> (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</p>
  
  <p><strong>What i tried :</strong></p>
  
  <ul>
  <li>make "strong references" so the gc dont delete it with:</li>
  </ul>
  
  <pre><code>    id: id.__self__
  </code></pre>
  
  <p>in my kv file</p>
  
  <ul>
  <li>make "strong references" with :</li>
  </ul>
  
  <pre><code>     self.refs = [
                  self.id.__self__,
                  self.id.__self__]
  </code></pre>
  
  <p>-Use the ErrorHandler to handle the error but the error keep coming for ever</p>
  
  <p><strong>What I think cause the error but I have no idea how to fix it:</strong></p>
  
  <ul>
  <li><p>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) :</p>
  
  <p>C = Clock.schedule_interval(self.requestClient, 5)</p></li>
  <li><p>this information in the <a href="https://kivy.org/doc/stable/api-kivy.clock.html?highlight=clock#module-kivy.clock" rel="nofollow noreferrer">kivy clock documentation</a> :</p></li>
  </ul>
  
  <blockquote>
    <p>Important</p>
    
    <p>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</p>
  </blockquote>
  
  <p>Error :</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>Thanks for reading !</p>