Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to use rpc client in sync app? #147

Open
derfenix opened this issue Jul 16, 2018 · 6 comments
Open

Any way to use rpc client in sync app? #147

derfenix opened this issue Jul 16, 2018 · 6 comments

Comments

@derfenix
Copy link

Is there any way to make sync client to communicate aiozmq.rpc server? I meen any solution ready to use.

@JelleZijlstra
Copy link
Collaborator

aiozmq isn't intended for use in synchronous apps, but it should be possible to make async functions blocking by wrapping them in e.g. asyncio.run.

@derfenix
Copy link
Author

I just meen if there any sync client uses the same messages format? I need to connect to rpc server on aiozmq.rpc from django app. So I need to choose - use aiozmq.rpc or use other package with ready sync clients.

@akhilman
Copy link

@derfenix seems like zmq_rpc is compatible with aoizmq.rpc.

@derfenix
Copy link
Author

@akhilman Thanks, looks nice, but I've created a more simple version already, containing only client in one file. Just rewrite async version without async. May be this will be usefull for somebody else.
https://gist.github.com/derfenix/f18e4a8f0ee9bad738c2b22106a3ad4d

@akhilman
Copy link

@derfenix thank you. I did my own non asyncio client using your code.
https://gist.github.com/akhilman/6f4aa516a7317f36ebac427a9d392865
My client produces futures and doesn't block process until result() method called.
It looks like:

futures = [rpc.method_one(), rpc.method_two()]
result_one, result_two = [fut.result() for fut in futures]

@trollfot
Copy link

@akhilman Hello, thank you very much for the code example. Would you have an up to date version on hand or the will to actually publish this as a package, so we could maintain it ?

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants