Thread lag

2009-04-25 Thread Asterix
Hi,

Here is a small class I use in my GTK application, to do some job in a
thread.:

class ThreadInterface:
   def __init__(self, func, func_args, callback, callback_args):
  '''Call a function in a thread and then call callback'''
  def thread_function(func, func_args, callback, callback_args):
 print 'func start'
 output = func(*func_args)
 gobject.idle_add(callback, output, *callback_args)
  Thread(target=thread_function, args=(func, func_args, callback,
 callback_args)).start()
  print 'thread called'

Here is the way I call the class:

def decrypt_thread(encmsg, keyID):
   # Do things
   return val1, val2)

def _on_message_decrypted(output, val):
   # blabla

ThreadInterface(decrypt_thread, [encmsg, keyID], _on_message_decrypted,
[val])


But between the time "thread called" is printed and the time "func
start" is printed, there is sometimes (it vary a lot) several seconds.

How could it be? Why thread is not started instantly? How can I improve
that?

Thanks for your help
--
http://mail.python.org/mailman/listinfo/python-list


compare unicode to non-unicode strings

2008-08-31 Thread Asterix
how could I test that those 2 strings are the same:

'séd' (repr is 's\\xc3\\xa9d')

u'séd' (repr is u's\\xe9d')
--
http://mail.python.org/mailman/listinfo/python-list