def pyspace_shmem(shmem_name): nothrow(ExistentialError, unlink_shared_memory, (shmem_name, )) nothrow(ExistentialError, unlink_semaphore, ('/pyspace_%s_lock' % shmem_name, )) with pyspaces.PySpaceShMem(shmem_name) as space: yield space unlink_shared_memory(shmem_name) unlink_semaphore('/pyspace_%s_lock' % shmem_name)
def main(): t = ('hello', 'world') print('producing tuple: %s' % str(t)) with pyspaces.PySpaceShMem('HelloWorldPyspace') as space: space.put(t)
def main(): with pyspaces.PySpaceShMem('HelloWorldPyspace') as space: print('consuming tuple: %s' % str(space.take(('hello', None))))
def main(args): operation = args[1] tupletype = args[2] level = args[3] print('operation: %s' % operation) print('tupletype: %s' % tupletype) print('level: %s' % level) tg = None if tupletype == "null": def _tg(): while True: yield (None, None) tg = _tg() elif tupletype == "int": def _tg(): while True: yield (randint(), randint()) tg = _tg() elif tupletype == "string": def _tg(): while True: yield (randstring(32), randstring(32)) tg = _tg() elif tupletype == "doublearray": def _tg(): while True: yield (randdoublearray(32), randdoublearray(32)) tg = _tg() elif tupletype == "doublearrayxl": def _tg(): while True: yield (randdoublearray(256), randdoublearray(256)) tg = _tg() elif tupletype == "doublearrayxxl": def _tg(): while True: yield (randdoublearray(2048), randdoublearray(2048)) tg = _tg() else: raise Exception("unsupported tupletype %s", tupletype) with pyspaces.PySpaceShMem('PutTakeMicroBenchPyspace') as space: space.put((None, )) if operation == "put": experiment_put(space, tg, level) elif operation == "take": experiment_take(space, tg, level) else: raise Exception("unsupported operation %s", operation)
def main(): with pyspaces.PySpaceShMem('ConnectMicroBenchPyspace') as space: space.put((None, ))