{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Pyro4\n\nThis demo shows an example on how to the Pyro4 package.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import Pyro4\nimport numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define random generator class and register the host. \n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "class RandGenerator(object):\n def getRand(self, x, y):\n return list(np.random.rand(y, x))\n\ndaemon = Pyro4.Daemon(host=\"129.69.65.61\", port=12000)\nuri = daemon.register(RandGenerator(), \"123456\")\nprint(\"uri=\", uri)\ndaemon.requestLoop()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In Order to get it from another computer use following code:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import Pyro4\nthing = Pyro4.Proxy(\"PYRO:123456@129.69.65.61:12000\")\nprint(thing.getRand(42,43))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }