import os
import sys
import dbus

class LogWriter:
	def __init__(self, application):
		self._application = application
		bus = dbus.SessionBus()
		proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
		self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')

	def start(self):
		if os.environ.has_key('SUGAR_USE_CONSOLE'):
			sys.stdout = self
			sys.stderr = self

	def write(self, s):
		self._logger.log(self._application, s)			

import os
import sys
import dbus
import gobject

class LogWriter:
	def __init__(self, application):
		self._application = application
		bus = dbus.SessionBus()
		proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
		self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')

	def start(self):
		if os.environ.has_key('SUGAR_USE_CONSOLE'):
			sys.stdout = self
			sys.stderr = self

	def write(self, s):
		gobject.idle_add(self._write, s)			

	def _write(self, s):
		self._logger.log(self._application, s)
		return False

Add messages on idle so that we don't break
Add messages on idle so that we don't break

  import os
  import sys
  import dbus
+ import gobject
  
  class LogWriter:
  	def __init__(self, application):
  		self._application = application
  		bus = dbus.SessionBus()
  		proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
  		self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')
  
  	def start(self):
  		if os.environ.has_key('SUGAR_USE_CONSOLE'):
  			sys.stdout = self
  			sys.stderr = self
  
  	def write(self, s):
- 		self._logger.log(self._application, s)			
+ 		gobject.idle_add(self._write, s)			
  
+ 	def _write(self, s):
+ 		self._logger.log(self._application, s)
+ 		return False
+ 
Add messages on idle so that we don't break
## Code Before:
import os
import sys
import dbus

class LogWriter:
	def __init__(self, application):
		self._application = application
		bus = dbus.SessionBus()
		proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
		self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')

	def start(self):
		if os.environ.has_key('SUGAR_USE_CONSOLE'):
			sys.stdout = self
			sys.stderr = self

	def write(self, s):
		self._logger.log(self._application, s)			

## Instruction:
Add messages on idle so that we don't break
## Code After:
import os
import sys
import dbus
import gobject

class LogWriter:
	def __init__(self, application):
		self._application = application
		bus = dbus.SessionBus()
		proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
		self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')

	def start(self):
		if os.environ.has_key('SUGAR_USE_CONSOLE'):
			sys.stdout = self
			sys.stderr = self

	def write(self, s):
		gobject.idle_add(self._write, s)			

	def _write(self, s):
		self._logger.log(self._application, s)
		return False
