def run(name): swap = SWAP.load(name) ce.Config.load(swap.config.online_name) Online.receive(swap) swap.save() ce.Config.instance().save() logger.debug('Saved swap status') logger.info('Sending reductions to caesar') Online.send(swap) logger.debug('Done sending reductions to caesar') code.interact(local={**globals(), **locals()})
def run_continuous(name): swap = SWAP.load(name) ce.Config.load(swap.config.online_name) try: logger.info('Starting SWAP (%s) in continuous online mode...' % name) while True: _, haveItems = Online.receive(swap) if haveItems: swap.save() ce.Config.instance().save() logger.debug('Saved swap status') logger.info('Sending reductions to caesar') Online.send(swap) logger.debug('Done sending reductions to caesar') except KeyboardInterrupt as e: logger.debug('Received KeyboardInterrupt {}'.format(e)) logger.debug('Terminating SWAP instance ({}).'.format(name)) return