Guest User

Untitled

a guest
Apr 27th, 2024
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. async def rtcWatchdog(uuid):
  2. global userUUIDAssociations
  3. print("Starting Watchdog")
  4. # While kill signal is false check uuid and if time goes over 5 seconds, then stop RTCPeer.
  5. while sigint == False:
  6. iPingtime = userUUIDAssociations[uuid][1]
  7. diffTime = float(time.time()) - float(iPingtime)
  8.  
  9. time.sleep(0.300)
  10. print("Found Pingtime: " + str(iPingtime))
  11. print("Diff time:" + str(diffTime))
  12.  
  13. if (diffTime > 5.0 and iPingtime > 0):
  14. print("Broken Watchdog, killing loop uuid: " + str(uuid))
  15. print("Running Threads Now: " + str(threading.active_count()))
  16.  
  17. try:
  18.  
  19. print("Is Running: " + str(userUUIDAssociations[uuid][2].is_running()))
  20. print("Is Closed: " + str(userUUIDAssociations[uuid][2].is_closed()))
  21. print("RtcConnectionState: ")
  22. print((userUUIDAssociations[uuid][5]).connectionState)
  23.  
  24. time.sleep(3)
  25.  
  26. print("Attempting to stop loop")
  27. userUUIDAssociations[uuid][2].stop() # Close event loop, which reduces thread count back to what it was originally. <---- THIS WAS A BIG FIX, now does not work? Never worked?
  28. print("Loop stopped")
  29.  
  30. print("Is Running: " + str(userUUIDAssociations[uuid][2].is_running()))
  31. print("Is Closed: " + str(userUUIDAssociations[uuid][2].is_closed()))
  32. print("RtcConnectionState: ")
  33. print((userUUIDAssociations[uuid][5]).connectionState)
  34.  
  35. time.sleep(2)
  36.  
  37. # Remove from userUUIDAssociations
  38. del userUUIDAssociations[uuid]
  39.  
  40. print("Running Threads After: " + str(threading.active_count()))
  41.  
  42. print("At end of stopping event loop, should be all cleaned up.")
  43. break
  44. print("Should not have been printed")
  45.  
  46. except Exception as e:
  47. print("Failed in stopping event loop")
  48. print(e)
Advertisement
Add Comment
Please, Sign In to add comment