- 投稿者: みゅ
- カテゴリ: Python
- 優先度: 普通
- 状態: 完了
- 日時: 2010年03月09日 21時26分30秒
import Pyro.core
import time
class HelloGen(Pyro.core.ObjBase):
def __init__(self):
Pyro.core.ObjBase.__init__(self)
def hi(self, name):
time.sleep(10)
return "Hi " + name + ", How's going?"
Pyro.core.initServer()
daemon = Pyro.core.Daemon()
uri = daemon.connect(HelloGen(), "hello")
print "The daemon runs on port:", daemon.port
print "The object's uri is:", uri
daemon.requestLoop()
$ python Pyro01.py
The daemon runs on port: 7766
The object's uri is: PYRO://127.0.0.1:7766/**********
import Pyro.core
# finds object automatically if you're running the Name Server.
jokes = Pyro.core.getProxyForURI("PYRO://127.0.0.1:7766/**********")
jokes.hi("test")
"Hi test, How's going?"
import Pyro.core
# finds object automatically if you're running the Name Server.
jokes = Pyro.core.getProxyForURI("PYROLOC://127.0.0.1:7766/hello")
jokes.hi("test")
"Hi test, How's going?"
R備忘録 /状態空間モデリング/donlp2/その他のメモ