~ubuntu-branches/ubuntu/trusty/cctools/trusty-proposed

« back to all changes in this revision

Viewing changes to work_queue/src/python/work_queue_example_2.py

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-10-26 11:51:10 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20111026115110-5pc2qxp03chldcdi
Tags: 3.4.0-1
* New upstream release.
* Improve DEP5 compliance of debian/copyright.
* Added patch to make "starch" use python instead of python2 as interpreter.
* Tighten build-dependencies (added swig and m4).
* Enable MPI-support for work-queue.
* Move to dh_python2.
* Split Python-bindings for workqueue into a dedicated package and build
  them for all supported Python versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import work_queue
 
4
import os
 
5
 
 
6
work_queue.set_debug_flag('all')
 
7
 
 
8
wq = work_queue.WorkQueue(port=work_queue.WORK_QUEUE_RANDOM_PORT, exclusive=False, shutdown=True)
 
9
wq.specify_name('test')
 
10
 
 
11
for i in range(5):
 
12
    task = work_queue.Task('date')
 
13
    task.specify_algorithm(work_queue.WORK_QUEUE_SCHEDULE_FCFS)
 
14
    task.specify_tag('current date/time [%d]' % i)
 
15
    task.specify_input_file('/bin/date')
 
16
 
 
17
    print task.id
 
18
    print task.algorithm
 
19
    print task.command
 
20
    print task.tag
 
21
 
 
22
    wq.submit(task)
 
23
 
 
24
os.system('work_queue_worker -d all -t 5 localhost %d &' % wq.port)
 
25
 
 
26
while not wq.empty():
 
27
    print '** wait for task'
 
28
    task = wq.wait(1)
 
29
    if task:
 
30
        print 'task'
 
31
        print 'algorithm', task.algorithm
 
32
        print 'command', task.command
 
33
        print 'tag', task.tag
 
34
        print 'output', task.output
 
35
        print 'id', task.id
 
36
        print task.preferred_host
 
37
        print task.status
 
38
        print task.return_status
 
39
        print task.result
 
40
        print task.host
 
41
        print task.submit_time
 
42
        print task.start_time
 
43
        print task.finish_time
 
44
        print task.transfer_start_time
 
45
        print task.computation_time
 
46
        print task.total_bytes_transferred
 
47
        print task.total_transfer_time
 
48
        del task
 
49
    print '** work queue'
 
50
    print wq.stats.workers_init
 
51
    print wq.stats.workers_ready
 
52
    print wq.stats.workers_busy
 
53
    print wq.stats.tasks_running
 
54
    print wq.stats.tasks_waiting
 
55
    print wq.stats.tasks_complete
 
56
    print wq.stats.total_tasks_dispatched
 
57
    print wq.stats.total_tasks_complete
 
58
    print wq.stats.total_workers_joined
 
59
    print wq.stats.total_workers_removed
 
60
    print wq.stats.total_bytes_sent
 
61
    print wq.stats.total_bytes_received
 
62
    print wq.stats.total_send_time
 
63
    print wq.stats.total_receive_time