New context manager API

3 views
Skip to first unread message

snim2

unread,
Oct 17, 2010, 4:55:11 PM10/17/10
to python-csp
Hi everyone,

just a couple of updates... I've been massively busy with the new
Semester, but I'm hoping to pick up the pace of things in the next few
weeks, and move towards the merger with PyCSP. Thanks for the bug
reports and so on that people have left on the list, I'll be going
through them systematically over the next fortnight or so.

In the mean time, during #flossuk I managed to hack up a quick version
of the context manager that Russel suggested, which gives a sort of
pseudo-OCCAM syntax to python-csp. It can be found in csp/csp.py and
tests/test_contexts.py although, as ever, it needs proper unit
testing. I haven't added docs to the Tutorial yet, but this is how it
is intended to be used:

from csp.csp import CSP

p = CSP()
with p.SEQ: # Execute the following functions in sequence
p.process(myfunction1, arg1, arg2)
with p.PAR: # Execute the following functions in parallel
p.process(myfunction2, arg1, arg2)
p.process(myfunction3, arg1, arg2)
p.process(myfunction4, arg1, arg2) # Back to serial...

p.start() # Start all that running now...


All the best,

Sarah

Tony Ibbs

unread,
Oct 18, 2010, 3:22:17 PM10/18/10
to pytho...@googlegroups.com

On 17 Oct 2010, at 21:55, snim2 wrote:

> In the mean time, during #flossuk I managed to hack up a quick version
> of the context manager that Russel suggested, which gives a sort of
> pseudo-OCCAM syntax to python-csp.

> from csp.csp import CSP


>
> p = CSP()
> with p.SEQ: # Execute the following functions in sequence
> p.process(myfunction1, arg1, arg2)
> with p.PAR: # Execute the following functions in parallel
> p.process(myfunction2, arg1, arg2)
> p.process(myfunction3, arg1, arg2)
> p.process(myfunction4, arg1, arg2) # Back to serial...
>
> p.start() # Start all that running now...

Ooooh - that's pretty!

Tibs

Reply all
Reply to author
Forward
0 new messages