mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-04 05:47:05 +00:00 
			
		
		
		
	Fixed an issue related to high CPU Usage when Streaming is enabled. Closes #220
This commit is contained in:
		@@ -127,12 +127,11 @@ class Controller(object):
 | 
				
			|||||||
  pub.subscribe(self.manage_item_in_list, "item-in-list")
 | 
					  pub.subscribe(self.manage_item_in_list, "item-in-list")
 | 
				
			||||||
  pub.subscribe(self.on_tweet_deleted, "tweet-deleted")
 | 
					  pub.subscribe(self.on_tweet_deleted, "tweet-deleted")
 | 
				
			||||||
  pub.subscribe(self.manage_stream_errors, "stream-error")
 | 
					  pub.subscribe(self.manage_stream_errors, "stream-error")
 | 
				
			||||||
  pub.subscribe(self.restart_streams, "restart-streams")
 | 
					#  pub.subscribe(self.restart_streams, "restart-streams")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 def bind_other_events(self):
 | 
					 def bind_other_events(self):
 | 
				
			||||||
  """ Binds the local application events with their functions."""
 | 
					  """ Binds the local application events with their functions."""
 | 
				
			||||||
  log.debug("Binding other application events...")
 | 
					  log.debug("Binding other application events...")
 | 
				
			||||||
  pub.subscribe(self.restart_streams_, "restart_streams")
 | 
					 | 
				
			||||||
  pub.subscribe(self.buffer_title_changed, "buffer-title-changed")
 | 
					  pub.subscribe(self.buffer_title_changed, "buffer-title-changed")
 | 
				
			||||||
  pub.subscribe(self.manage_sent_dm, "sent-dm")
 | 
					  pub.subscribe(self.manage_sent_dm, "sent-dm")
 | 
				
			||||||
  widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
 | 
					  widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
 | 
				
			||||||
@@ -266,6 +265,8 @@ class Controller(object):
 | 
				
			|||||||
  self.checker_function.start()
 | 
					  self.checker_function.start()
 | 
				
			||||||
  self.save_db = RepeatingTimer(300, self.save_data_in_db)
 | 
					  self.save_db = RepeatingTimer(300, self.save_data_in_db)
 | 
				
			||||||
  self.save_db.start()
 | 
					  self.save_db.start()
 | 
				
			||||||
 | 
					  self.update_buffers_function = RepeatingTimer(60, self.update_buffers)
 | 
				
			||||||
 | 
					  self.update_buffers_function.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 def start(self):
 | 
					 def start(self):
 | 
				
			||||||
  """ Starts all buffer objects. Loads their items."""
 | 
					  """ Starts all buffer objects. Loads their items."""
 | 
				
			||||||
@@ -1587,9 +1588,9 @@ class Controller(object):
 | 
				
			|||||||
  if hasattr(self, action):
 | 
					  if hasattr(self, action):
 | 
				
			||||||
   getattr(self, action)()
 | 
					   getattr(self, action)()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 def restart_streams_(self, session):
 | 
					 def update_buffers(self):
 | 
				
			||||||
  for i in self.buffers[:]:
 | 
					  for i in self.buffers[:]:
 | 
				
			||||||
   if i.session != None and i.session.session_id == session:
 | 
					   if i.session != None and i.session.is_logged == True:
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
     i.start_stream()
 | 
					     i.start_stream()
 | 
				
			||||||
    except TwythonAuthError:
 | 
					    except TwythonAuthError:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -395,13 +395,13 @@ class Session(object):
 | 
				
			|||||||
   self.logged = False
 | 
					   self.logged = False
 | 
				
			||||||
   self.twitter = twitter.twitter.twitter()
 | 
					   self.twitter = twitter.twitter.twitter()
 | 
				
			||||||
   self.login(False)
 | 
					   self.login(False)
 | 
				
			||||||
   pub.sendMessage("restart_streams", session=self.session_id)
 | 
					 | 
				
			||||||
  if self.reconnection_function_active == True:  return
 | 
					  if self.reconnection_function_active == True:  return
 | 
				
			||||||
  self.reconnection_function_active = True
 | 
					  self.reconnection_function_active = True
 | 
				
			||||||
  if not hasattr(self, "main_stream") or not application.streaming_lives():
 | 
					  if not hasattr(self, "main_stream") or not application.streaming_lives():
 | 
				
			||||||
   self.get_main_stream()
 | 
					   self.get_main_stream()
 | 
				
			||||||
  if not hasattr(self, "timelinesStream") or application.streaming_lives():
 | 
					  if not hasattr(self, "timelinesStream") or application.streaming_lives():
 | 
				
			||||||
   self.get_timelines()
 | 
					   self.get_timelines()
 | 
				
			||||||
 | 
					  self.counter = 0
 | 
				
			||||||
  self.reconnection_function_active = False
 | 
					  self.reconnection_function_active = False
 | 
				
			||||||
  if hasattr(self, "timelinesStream") and not hasattr(self.timelinesStream, "friends"):
 | 
					  if hasattr(self, "timelinesStream") and not hasattr(self.timelinesStream, "friends"):
 | 
				
			||||||
   self.add_friends()
 | 
					   self.add_friends()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user