-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessor.py
More file actions
55 lines (45 loc) · 1.38 KB
/
accessor.py
File metadata and controls
55 lines (45 loc) · 1.38 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Pyro4
import random
from threading import Thread
import pickle
import socket
# import pydo
Pyro4.config.REQUIRE_EXPOSE = False
class SharedObject(object):
pass
# def __init__(self):
# self.name = "shit"
# print self.name
# def get_name(self):
# return self.name
# def get_server(self):
# with open("pydo.object", "r") as f:
# return pickle.load(f)
# def __getattribute__(self, name):
# """ Intercept calls to any of the methods in the child object """
# attr = object.__getattribute__(self, name)
# if hasattr(attr, '__call__'):
# def newfunc(*args, **kwargs):
# # Allow async calls to methods (promises)
# if 'async' in kwargs: del kwargs['async']
# obj = Pyro4.Proxy(self.name)
# print obj
# return obj.perform()
# # result = func(*args, **kwargs)
# # return result
# return newfunc
# else:
# return attr
class Counter(SharedObject):
def __init__(self):
# super(Counter, self).__init__()
self.count = 10
def perform(self):
return "Hey yo!"
def get_server():
with open("pydo.object", "r") as f:
print dir(pickle.load(f))
if __name__ == "__main__":
c1 = Counter()
c2 = Counter()
c3 = Counter()