Skip to content

Instantly share code, notes, and snippets.

@codemation
Last active December 25, 2020 20:15
Show Gist options
  • Save codemation/5619471189c71a9c313fb5c21d155cdd to your computer and use it in GitHub Desktop.
Save codemation/5619471189c71a9c313fb5c21d155cdd to your computer and use it in GitHub Desktop.
# subprocess job template for easyrpc_job_runner
import asyncio, sys, json
from easyrpc.proxy import EasyRpcProxy
async def job(reuest_id, payload):
proxy = await EasyRpcProxy.create(
'0.0.0.0',
8690,
'/ws/jobs',
server_secret='abcd1234',
namespace='jobs'
)
# insert work here
results = 'subprocess results' # dont use this
await proxy['send_results'](request_id, results)
if __name__ == '__main__':
payload = json.load(sys.stdin)
request_id = sys.argv[1]
asyncio.run(job(request_id, payload))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment