-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpydo.py
More file actions
30 lines (27 loc) · 726 Bytes
/
pydo.py
File metadata and controls
30 lines (27 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Pyro4
from Pyro4 import Daemon
from threading import Thread
import thread
import pickle
import socket
Pyro4.config.SERVERTYPE = "multiplex"
Pyro4.expose(Daemon)
daemon = Pyro4.Daemon(host="localhost", port=4040)
uri = daemon.register(daemon)
print uri
with Pyro4.locateNS() as ns:
ns.register("Namespace", uri)
print "Registered to namespace"
daemon.requestLoop()
def register(obj):
daemon = Pyro4.Daemon(host="localhost", port=4040)
uri = daemon.register(obj) # Scheduler
with Pyro4.locateNS() as ns:
ns.register("Namespace", uri)
print "Registered to namespace"
serve_daemon(daemon)
return uri
def serve_daemon(daemon):
print "Serving daemon"
t = Thread(target=lambda: daemon.requestLoop())
t.start()