Example #1
0
    def __init__(self):
        """ Class constructor """
        self.pool = []

        server = socket(AF_INET, SOCK_STREAM)
        server.bind(('127.0.0.1', 0))
        server.listen(1)

        client = Dead()
        client.connect_ex(server.getsockname())

        def consume(spin):
            spin.recv(self.MAX_SIZE)

        xmap(client, READ, consume)

        self.register(client)
        self.bell, addr = server.accept()
        self.lock       = Lock()
Example #2
0
    def __init__(self):
        """ Class constructor """
        self.pool = []

        server = socket(AF_INET, SOCK_STREAM)
        server.bind(('127.0.0.1', 0))
        server.listen(1)

        client = Dead()
        client.connect_ex(server.getsockname())

        def consume(spin):
            spin.recv(self.MAX_SIZE)

        xmap(client, READ, consume)

        self.register(client)
        self.bell, addr = server.accept()
        self.lock = Lock()
Example #3
0
from untwisted.job import Job, DONE
from untwisted import core
from untwisted.usual import xmap
import time

def sum(x, y):
    time.sleep(3)
    return x + y

def show(job, result):
    print result

for ind in xrange(100):
    job = Job(sum, ind, 1000)
    xmap(job, DONE, show)

core.gear.mainloop()



Example #4
0
from untwisted.job import Job, DONE
from untwisted import core
from untwisted.usual import xmap
import time


def sum(x, y):
    time.sleep(3)
    return x + y


def show(job, result):
    print result


for ind in xrange(100):
    job = Job(sum, ind, 1000)
    xmap(job, DONE, show)

core.gear.mainloop()
Example #5
0
from untwisted.expect import Expect, LOAD, CLOSE
from untwisted import core
from untwisted.usual import xmap, die

def handle(expect, data):
    print data

expect = Expect('python', '-i', '-u')
xmap(expect, LOAD, handle)
xmap(expect, CLOSE, lambda expect: die())
expect.send('print "hello world"\nquit()\n')
core.gear.mainloop()