Last active
December 25, 2020 20:15
-
-
Save codemation/7915bf2987c83f44f18fe08db7918d3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# job manager to be used to add jobs / get results from an easyrpc job runner | |
import asyncio, sys, json | |
from easyrpc.proxy import EasyRpcProxy | |
async def get_proxy(): | |
proxy = await EasyRpcProxy.create( | |
'0.0.0.0', | |
8690, | |
'/ws/jobs', | |
server_secret='abcd1234', | |
namespace='jobs' | |
) | |
return proxy | |
async def async_add_job(payload, job_type): | |
proxy = await get_proxy() | |
request_id = await proxy['process_payload'](payload, job_type) | |
return request_id | |
async def async_get_results(request_id): | |
proxy = await get_proxy() | |
results = await proxy['get_results']() | |
return results | |
def get_results(request_id): | |
return asyncio.run(async_get_results(request_id)) | |
def add_job(payload, job_type): | |
return asyncio.run(async_add_job(payload, job_type)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment