Package qubx :: Module task :: Class Task
[hide private]
[frames] | no frames]

Class Task

source code

object --+
         |
        Task
Known Subclasses:

A worker thread; not started until .start().

From inside the thread, trigger the callback On* by calling send_*(). The callback will then fire from the main thread.

Instance Methods [hide private]
 
__init__(self, label)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
set_progress(self, x)
Updates progress and calls OnProgress in the main thread.
source code
 
set_status(self, x)
Updates status and calls OnStatus in the main thread.
source code
 
send_result(self, x)
Calls OnResult in the main thread.
source code
 
send_exception(self)
Calls OnException in the main thread.
source code
 
send_progress(self, x)
Calls OnProgress in the main thread.
source code
 
send_status(self, x)
Calls OnStatus in the main thread.
source code
 
start(self)
Starts the Task thread.
source code
 
interrupt(self)
Raises KeyboardInterrupt in the Task thread.
source code
 
join(self)
Waits for the Task thread to finish.
source code
 
thread_main(self)
Calls run, then makes sure OnTerminate is called in the main thread.
source code
 
run(self)
Override this method to make the Task thread do something.
source code
 
gui_call_recv(self, fn, *args, **kw)
Calls fn(*args, **kw) in the gtk main thread, waits for self(*results) to be called, and returns results (a tuple).
source code
 
__call__(self, *args) source code
 
idle_wait(self, fn, *args, **kw)
Returns the result of fn(*args, **kw) called in the gtk main thread; calling thread pauses until fn completes.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  progress
percent complete, between 0.0 and 100.0
  status
message string
  OnException
qubx.util_types.WeakEvent(Task, type, value, traceback)
  OnInterrupt
qubx.util_types.WeakEvent(Task, cancel()) if you want to do more/less than KeyboardInterrupt
  OnProgress
qubx.util_types.WeakEvent(Task, progress)
  OnResult
qubx.util_types.WeakEvent(Task, result)
  OnStatus
qubx.util_types.WeakEvent(Task, status)
  OnTerminate
qubx.util_types.WeakEvent(Task)
  label
descriptive string
  main_hold
GTK_Main_Hold to pause the main thread
  tid
thread id
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, label)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

gui_call_recv(self, fn, *args, **kw)

source code 

Calls fn(*args, **kw) in the gtk main thread, waits for self(*results) to be called, and returns results (a tuple). Intended for long-running requests that return via callback:

>>> data = task.gui_call_recv(call_with_data, task)

Instance Variable Details [hide private]

progress

percent complete, between 0.0 and 100.0
Get Method:
unreachable(self)
Set Method:
unreachable(self, x)

status

message string
Get Method:
unreachable(self)
Set Method:
unreachable(self, x)