Changeset 9102 for main


Ignore:
Timestamp:
9 Aug 2012, 09:52:28 (12 years ago)
Author:
uli
Message:

Support duration setting for async test jobs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/async.py

    r9082 r9102  
    3535    )
    3636
    37 def compute(num):
     37def compute(num, duration=60):
    3838    """A convenience function to test asynchronous jobs.
     39
     40    `duration` gives the seconds, this job should (artificially) need
     41    for completing.
    3942    """
    4043    start = time.time()
    41     duration = 60
    4244    end = start + duration
    4345    print "MyJob starts computation at ", start
     
    6062        print "MyJob's percent: %r" % zc.async.local.getLiveAnnotation(
    6163            'percent')
     64    zc.async.local.setLiveAnnotation('percent', 100.0)
    6265    return num * 2
    6366
     
    7073    grok.implements(IJob, IProgressable)
    7174    grok.provides(IJob)
    72 
    7375    percent = None
    7476
     
    183185        return
    184186
    185     def start_test_job(self):
     187    def start_test_job(self, duration=60, site=None):
    186188        """Start a test job.
    187189
     
    190192        :func:`compute` function with ``23`` as argument.
    191193        """
    192         job = AsyncJob(compute, 23)
    193         job_id = self.put(job)
     194        job = AsyncJob(compute, 23, duration)
     195        job_id = self.put(job, site=site)
    194196        return job_id
    195197
Note: See TracChangeset for help on using the changeset viewer.