Re: [gedit-list] Multithreading in gedit plugins



Michael Zeising wrote:

Hi there,

I need to execute some tasks in parallel threads to not block gedit. To initialize threading in PyGTK, I'm running "gtk.gdk.threads_init()" at the top of my plugin's "__init__.py".

To thread a method I use the following decorator:

-----
import threading

def threaded(f):
    """
    Threaded decorator
    """
    def wrapper(*args):
        t = threading.Thread(target=f, args=args)
        t.start()
    return wrapper
-----

When I apply this decorator like

-----
@threaded
def parseSomething(self):
    do_stuff()
-----

the method is _never_ run and a segmentation fault occurs when I quit gedit.

Has anyone of you experienced this yet? I'd be really thankful for any hint on how to solve this!


Thanks,
Michael
_______________________________________________
gedit-list mailing list
gedit-list gnome org
http://mail.gnome.org/mailman/listinfo/gedit-list

   Hello,

This question comes up once in awhile. As far as I understand, the way GEdit is using Python's global interpreter lock, you can't run Python threads. Maybe you should check the archives - I once wrote a more referenced reply.

   Bye,

   Ami


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