Example #1
0
def application(environ, start_response):
    headers = []
    headers.append(('Content-Type', 'text/html'))
    write = start_response('200 OK', headers)

    #if not tio_connection:
    tio_connection = tioclient.Connect(environ['tio.server'])

    form = cgi.FieldStorage(fp=environ['wsgi.input'],
                            environ=environ,
                            keep_blank_values=True)

    ret = doit(tio_connection, form)
    #ret.extend(dump_environ(environ))

    tio_connection.close()

    return ret
Example #2
0
def get_tio(server):
    thread_id = threading.current_thread().ident

    with tls_lock:
        thread_data = tls_data.get(thread_id, {})
        try:
            tio = thread_data[server]
            try:
                tio.ping()
                return tio
            except:
                pass  # will recreate the connection below
        except KeyError:
            pass

        tio = tioclient.Connect(server)
        thread_data[server] = tio
        return tio
import random
import tioclient
tio = tioclient.Connect('tio://127.0.0.1:12345')
source = tio.CreateContainer('factorial_cluster/source', 'volatile_list')
destination = tio.CreateContainer('factorial_cluster/destination',
                                  'volatile_list')

source.set_property('destination', 'factorial_cluster/destination')


def OnItemDone(container, event_name, key, value, metadata):
    print value


destination.subscribe(OnItemDone)

# add 10k integers from 1 to 500
item_count = 10 * 1000
for x in range(item_count):
    source.append(random.randint(1, 500))

print 'generated %d items, now waiting for results' % item_count

tio.RunLoop()