Ejemplo n.º 1
0
def runBlock_gui(func, args=(), kwargs={}):
    if thread_enable.query() and not mainthread.mainthread():
        callbackobj = OOFIdleBlockCallback(func, args, kwargs)
        callbackobj.event.clear()
        gobject.idle_add(callbackobj, priority=gobject.PRIORITY_LOW)
        callbackobj.event.wait()
        return callbackobj.result
    else:
        return func(*args, **kwargs)
Ejemplo n.º 2
0
def runBlock_gui(func, args=(), kwargs={}):
    if thread_enable.query() and not mainthread.mainthread():
        callbackobj = OOFIdleBlockCallback(func, args, kwargs)
        callbackobj.event.clear()
        gobject.idle_add(callbackobj, priority=gobject.PRIORITY_LOW)
        callbackobj.event.wait()
        return callbackobj.result
    else:
        return func(*args, **kwargs)
Ejemplo n.º 3
0
 def append(self, cmd, *args):
     ## adds a command and its arguments to the list
     if self.destroyflag:
         self.purge()
         if not mainthread.mainthread():
             raise subthread.StopThread
     self.lock.acquire()
     self.buf.append((cmd, args))
     self.lock.release()
     if len(self.buf) > BUFSIZE:
         self.flush()
Ejemplo n.º 4
0
def getThreadedWorker(menuitem, argtuple, argdict):
    if not thread_enable.query():
        return worker.NonThreadedWorker(menuitem, argtuple, argdict)
    if mainthread.mainthread():
        return worker.ThreadedWorker(menuitem, argtuple, argdict)
    # Threading is enabled, but this isn't the main thread.  We must
    # be running a script, because that is the only way to create
    # workers that don't start on the main thread.  Scripts can't run
    # their commands concurrently, so we need to create a worker that
    # blocks until the command finishes.
    return GUIThreadedWorkerBlock(menuitem, argtuple, argdict)
Ejemplo n.º 5
0
def getThreadedWorker(menuitem, argtuple, argdict):
    if not thread_enable.query():
        return worker.NonThreadedWorker(menuitem, argtuple, argdict)
    if mainthread.mainthread():
        return worker.ThreadedWorker(menuitem, argtuple, argdict)
    # Threading is enabled, but this isn't the main thread.  We must
    # be running a script, because that is the only way to create
    # workers that don't start on the main thread.  Scripts can't run
    # their commands concurrently, so we need to create a worker that
    # blocks until the command finishes.
    return GUIThreadedWorkerBlock(menuitem, argtuple, argdict)
Ejemplo n.º 6
0
 def append(self, cmd, *args):
     ## adds a command and its arguments to the list
     if self.destroyflag:
         self.purge()
         if not mainthread.mainthread():
             raise subthread.StopThread
     self.lock.acquire()
     self.buf.append((cmd, args))
     self.lock.release()
     if len(self.buf) > BUFSIZE:
         self.flush()
Ejemplo n.º 7
0
def getThreadedParallelWorker(menuitem, argtuple, argdict):
    ## parallel workers
    ## only called by front-end
    ## back-end is running on text-mode, without any text
    ## progress bars
    if not thread_enable.query():
        ## if GUI is not in place yet, do not
        ## launch a thread. Instead run a serial
        ## parallel worker
        return worker.ParallelWorker(menuitem, argtuple, argdict)
    if mainthread.mainthread():
        ## if main thread launches a parallel thread
        ## launch a GUI worker
        return GUIParallelThreadedWorker(menuitem, argtuple, argdict)
    ## if subthread is attempting to launch a thread,
    ## block the subthread, until, sub-subthread joins
    return GUIParallelThreadedWorkerBlock(menuitem, argtuple, argdict)
Ejemplo n.º 8
0
def getThreadedParallelWorker(menuitem, argtuple, argdict):
    ## parallel workers
    ## only called by front-end
    ## back-end is running on text-mode, without any text
    ## progress bars
    if not thread_enable.query():
        ## if GUI is not in place yet, do not 
        ## launch a thread. Instead run a serial
        ## parallel worker
        return worker.ParallelWorker(menuitem, argtuple, argdict)
    if mainthread.mainthread():
        ## if main thread launches a parallel thread
        ## launch a GUI worker
        return GUIParallelThreadedWorker(menuitem, argtuple, argdict)
    ## if subthread is attempting to launch a thread,
    ## block the subthread, until, sub-subthread joins
    return GUIParallelThreadedWorkerBlock(menuitem, argtuple, argdict)
Ejemplo n.º 9
0
 def isTopLevel(self):
     return mainthread.mainthread()
Ejemplo n.º 10
0
def subthreadTest():
    if _debug_mode:
        if thread_enable.query() and mainthread.mainthread():
            fmsg("IN MAIN THREAD")
            dumpTrace()
            os.abort()
Ejemplo n.º 11
0
def mainthreadTest():
    if _debug_mode:
        if not mainthread.mainthread():
            fmsg("NOT IN MAIN THREAD")
            dumpTrace()
            os.abort()
Ejemplo n.º 12
0
def subthreadTest():
    if _debug_mode:
        if thread_enable.query() and mainthread.mainthread():
            fmsg("IN MAIN THREAD")
            dumpTrace()
            os.abort()
Ejemplo n.º 13
0
def mainthreadTest():
    if _debug_mode:
        if not mainthread.mainthread():
            fmsg("NOT IN MAIN THREAD")
            dumpTrace()
            os.abort()
Ejemplo n.º 14
0
 def isTopLevel(self):
     return mainthread.mainthread()