/
setup.py
129 lines (97 loc) · 3.5 KB
/
setup.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: utf-8 -*-
"""
Zeronimo
~~~~~~~~
A distributed RPC solution based on ØMQ_ and gevent_. Follow the features:
- A worker can return, yield, raise any picklable object to the remote
customer.
- A customer can invoke to any remote worker in the worker cluster.
- A customer can invoke to all remote workers in the worker cluster.
.. _ØMQ: http://www.zeromq.org/
.. _gevent: http://gevent.org/
Example
=======
Server-side
-----------
The address is 192.168.0.41. The worker will listen at 24600.
.. sourcecode:: python
import zmq.green as zmq
import zeronimo
class Application(object):
def rycbar123(self):
for word in 'run, you clever boy; and remember.'.split():
yield word
ctx = zmq.Context()
# make worker
worker_sock = ctx.socket(zmq.PULL)
worker_sock.bind('tcp://*:24600')
worker = zeronimo.Worker(Application(), [worker_sock])
# run worker forever
worker.run()
Client-side
-----------
The address is 192.168.0.42. The reply collector will listen at 24601.
.. sourcecode:: python
import zmq.green as zmq
import zeronimo
ctx = zmq.Context()
# make remote result collector
collector_sock = ctx.socket(zmq.PULL)
collector_sock.bind('tcp://*:24601)
collector = zeronimo.Collector(collector_sock, 'tcp://192.168.0.42:24601')
# make customer
customer_sock = ctx.socket(zmq.PUSH)
customer_sock.connect('tcp://192.168.0.41:24600')
customer = zeronimo.Customer(customer_sock, collector)
# rpc
remote_result = customer.emit('rycbar123')
for line in remote_result.get():
print line
"""
from __future__ import with_statement
import os
import sys
from setuptools import setup
from setuptools.command.test import test
# prevent error in sys.exitfunc when testing.
__import__('zmq') if 'test' in sys.argv else None
# include __about__.py.
__dir__ = os.path.dirname(__file__)
about = {}
with open(os.path.join(__dir__, 'zeronimo', '__about__.py')) as f:
exec(f.read(), about)
# use pytest instead.
def run_tests(self):
raise SystemExit(__import__('pytest').main(['-v', '--all']))
test.run_tests = run_tests
setup(
name='zeronimo',
version=about['__version__'],
license=about['__license__'],
author=about['__author__'],
author_email=about['__author_email__'],
url='http://github.com/sublee/zeronimo/',
description='RPC between distributed workers',
long_description=__doc__,
platforms='any',
packages=['zeronimo'],
classifiers=['Development Status :: 1 - Planning',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development'],
install_requires=['gevent>=1', 'pyzmq>=14', 'six'],
test_suite='...',
tests_require=['pytest', 'pytest-rerunfailures',
'psutil', 'pylru', 'singledispatch'],
)