Re: Threading in a python extension?



On Sat, Jun 17, 2006 at 21:35:34 +0200, Christian Persch wrote:
>Hi,
>
>Le samedi 17 juin 2006 à 16:45 +0100, Magnus Therning a écrit :
>> Ive started looking at making epilicious (an epiphany extension,
>> written in Python, to synchronise local and Del.icio.us bookmarks)
>> giving the user a bit more feedback. My idea was to spawn off a thread
>> to do the actual synchronisation in order for the epiphany GUI to not
>> lock up. Later I'd look into displaying a progressbar.
>> 
>> Unfortunately I got stuck on the first step. I create a threading.Thread
>> object, passing in the synchronisation function as its target argument.
>> Then I start the thread:
>> 
>>  def _menu_callback(action, window):
>>    t = threading.Thread(target=_do_sync)
>>    t.start()
>> 
>> I've added some calls to a logger (using logging.getLogger) first thing
>> both in _menu_callback and in _do_sync. The first one is hit, but the
>> second is never reached.
>> 
>> Is it possible to do a multi-threaded extension in Python at all?
>
>It should be possible to do threading as long as you're careful to only
>ever call gtk and epiphany functions from the main thread. There's at
>least on (C++) extension that uses threading, the error viewer's link
>validations functionality.

Ah, OK, so it's always an option to rewrite it in C (or C++) then.
That's good to know at least :-)

Does anyone have any examples of multi-threade extensions written in
Python?

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus therning org             Jabber: magnus therning gmail com
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Second Law:
Always keep a record of data -- it indicates you've been working.

Attachment: pgpLgL22Yyj3m.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]