Copyright (c) 2009 John Markus Bjoerndalen <*****@*****.**>, Brian Vinter <*****@*****.**>, Rune M. Friborg <*****@*****.**>. See LICENSE.txt for licensing details (MIT License). """ import sys sys.path.append("..") import pycsp.greenlets as pycsp @pycsp.process def readP(cin): cin() A = pycsp.Channel("A") pycsp.Spawn(1000000 * readP(A.reader())) cout = A.writer() for i in xrange(1000000): cout(i) if (i % 20000 == 0): sys.stdout.write(".") sys.stdout.flush() sys.stdout.write("done\n") pycsp.shutdown()
if __name__ == '__main__': swear_words = ["objects", "java", "php", "5"] whitelist = [("10.0.0.12", 0), ("10.0.0.12", 1), ("10.0.0.12", 2), ("10.0.0.12", 3), ("10.0.0.12", 4), # ("10.0.0.12", 5), ("10.0.0.12", 6), ("10.0.0.12", 7), ("10.0.0.12", 8), ("10.0.0.12", 9),] service = Channel() monitor_access = Channel() try: Parallel(server(whitelist, swear_words, service.reader(), monitor_access.reader()), [client(service.writer(), id) for id in xrange(10)], monitor(monitor_access.writer(), conn_to_id("10.0.0.12", 6)) ) except Exception as ex: if str(ex) == 'Deadlock': pass # All simulated clients and servers are shut down... time to terminate else: raise shutdown()
""" Copyright (c) 2009 John Markus Bjoerndalen <*****@*****.**>, Brian Vinter <*****@*****.**>, Rune M. Friborg <*****@*****.**>. See LICENSE.txt for licensing details (MIT License). """ import sys sys.path.append("..") import pycsp.greenlets as pycsp @pycsp.process def readP(cin): cin() A = pycsp.Channel("A") pycsp.Spawn(1000000 * readP(A.reader())) cout = A.writer() for i in xrange(1000000): cout(i) if (i%20000 == 0): sys.stdout.write(".") sys.stdout.flush() sys.stdout.write("done\n") pycsp.shutdown()