A python work server written in C
Project description
# MrWorkServer
A simple clustered python 3.5+ asyncio based work server that uses the MrQ interface.
# Example
```python
import asyncio
import mrworkserver
async def callback(msgs):
print("Callback:")
for m in msgs:
print(m)
ws = mrworkserver.WorkServer()
ws.cb = callback
ws.run()
```
# Example client
```python
# pip install asyncmrq mrjson
import asyncio
from mrq.client import Client
import mrjson
async def run(loop):
c = Client()
await c.connect(io_loop=loop,servers=[("127.0.0.1",7100)])
msg = mrjson.dumpb([1,2,3,4,5,6,7,8,9,10])
for x in range(10):
await c.push( 0, 0, msg, len(msg) )
await asyncio.sleep(1)
await c.close()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(run(loop))
loop.close()
```
A simple clustered python 3.5+ asyncio based work server that uses the MrQ interface.
# Example
```python
import asyncio
import mrworkserver
async def callback(msgs):
print("Callback:")
for m in msgs:
print(m)
ws = mrworkserver.WorkServer()
ws.cb = callback
ws.run()
```
# Example client
```python
# pip install asyncmrq mrjson
import asyncio
from mrq.client import Client
import mrjson
async def run(loop):
c = Client()
await c.connect(io_loop=loop,servers=[("127.0.0.1",7100)])
msg = mrjson.dumpb([1,2,3,4,5,6,7,8,9,10])
for x in range(10):
await c.push( 0, 0, msg, len(msg) )
await asyncio.sleep(1)
await c.close()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(run(loop))
loop.close()
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mrworkserver-0.3.tar.gz
(12.8 kB
view details)
File details
Details for the file mrworkserver-0.3.tar.gz
.
File metadata
- Download URL: mrworkserver-0.3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/32.3.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71a42c3e2fe1e6547a17d55f4e7767de321a476f34da47b28f0e5f343336c419 |
|
MD5 | a98af1064dd7f4aa9f74f1d3ec7e617d |
|
BLAKE2b-256 | 22cf2fb2de03a212be5944e8a4f9dfd36a244a4cfcbe39c7548bd5533f2e43b2 |