Module p.u.gthreads

Part of pida.utils

No module docstring
Line # Kind Name Docs
29 Class AsyncTask AsyncTask is used to help you perform lengthy tasks without delaying
89 Class GeneratorTask The diference between this task and AsyncTask is that the 'work_callback'
126 Class GeneratorSubprocessTask A Generator Task for launching a subprocess
161 Function locked 0 Call this decorator with the name of the lock. The decorated method
187 Function locked This is a factory of decorators. The decorator
216 Function gcall Calls a function, with the given arguments inside Gtk's main loop.
def locked 0(lockname):
Call this decorator with the name of the lock. The decorated method will be wrapped with an acquire()/lock().

Example of usage:

import threading

class Foo(object):
    def __init__(self):
        self.lock = threading.Lock()

    @locked("lock")
    def meth1(self):
        self.critical_value = 1

    @locked("lock")
    def meth2(self):
        self.critical_value = 2
        return self.critical_value

Both 'meth1' and 'meth2' will be wrapped with a 'lock.acquire()' and a 'lock.release()'.

def locked(lock_name):
This is a factory of decorators. The decorator wraps an acquire() and release() around the decorated method. The lock name is the name of the attribute containing the lock.
def gcall(func, *args, **kwargs):
Calls a function, with the given arguments inside Gtk's main loop.
Example::
    gcall(lbl.set_text, "foo")

If this call would be made in a thread there could be problems, using
it inside Gtk's main loop makes it thread safe.
API Documentation for PIDA, generated by pydoctor.