abingham / traad

An JSON+HTTP server for the rope Python refactoring library
MIT License
107 stars 20 forks source link

Switch back to synchronous RPC calls until xml-rpc gets fixed. #33

Closed abingham closed 11 years ago

abingham commented 11 years ago

Currently we don't seem to be getting return values properly from xml-rpc when we use async calls. This is bad because we can't give good feedback to users when things go wrong. Need to consider going back to sync calls, or perhaps finding a new xml-rpc lib (or jsonrpc lib?) for emacs.

tkf commented 11 years ago

If you are just targeting Emacs, how about my Python-EPC https://github.com/tkf/python-epc?

abingham commented 11 years ago

That's excellent! I dont' want to limit myself to just emacs, but I could certainly consider using your code for an emacs-specific server mode or something. I've filed a bug with the xml-rpc project, but I don't know how active they are. Plus the bug may be down in the url-http library or something. In any event, I'll look at your stuff when I get a chance.

abingham commented 11 years ago

We might also consider letting users choose between sync and async modes. Something like traad-use-async which would tell traad to use asynchronous calls when appropriate, and it would use sync otherwise. Then we could have the performance benefits of async most of the time, but we could have sync mode for debugging, etc.

At the same time, this is work purely for working around a defect. Hopefully we can just get the async stuff working properly.

tkf commented 11 years ago

I feel that networking library in Emacs is not actively developed. I filed a few bug reports to url.el (which is I think dependency for xml-rpc) but no reply so far. I wish they start using wget instead of url.el.

I think supporting both async and sync mode for all function must be hard. For debugging purpose, you can use deferred:sync! function if you use EPC. This is useful for testing and debugging.

abingham commented 11 years ago

I've added the traad-use-async variable. If this is true, then traad-call-async will use asynchronous calls. If it's false, then traad-call-async will use a synchronous call behind the scenes, and then call the callback directly. This should let most people continue to use asynchronous calls while allowing developers to debug things with synchronous calls.