PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/core/test_workers.py

https://bitbucket.org/prologic/circuits/
Python | 27 lines | 15 code | 8 blank | 4 comment | 3 complexity | b9165bd4e8a6dc8a3655f8b0960cf982 MD5 | raw file
 1# Module:   test_workers
 2# Date:     7th October 2008
 3# Author:   James Mills, prologic at shortcircuit dot net dot au
 4
 5"""Workers Tests"""
 6
 7from circuits import Task, Worker
 8
 9def f():
10    x = 0
11    i = 0
12    while i < 1000000:
13        x += 1
14        i += 1
15    return x
16
17def test():
18    w = Worker()
19
20    x = w.fire(Task(f))
21
22    while not x.result: pass
23
24    assert x.result
25    assert x.value == 1000000
26
27    w.stop()