Closed byaka closed 9 years ago
Actually, the (JSON-RPC specification)[http://www.jsonrpc.org/specification#notification] says:
[...] a Notification signifies the Client's lack of interest in the corresponding Response [...] The Server MUST NOT reply to a Notification
Technically, it is possible to start a new thread for each notification in jsonrpclib, to let the long process be done in background. But you won't be able to get any result afterwards. => This would need a relatively small work on jsonrpclib
Another solution would be to create a manager which will queue those calls and associate them to a UUID. That way, you can use a thread pool to control the number of threads, and you could poll a get_result(uid)
method to ask for the result regularly.
=> This could be a utility module in jsonrpclib, but it would require a little more work.
Second solution more flexible, but i'm think it complicate a library's logic.
I'll implement the first solution during next week, as it has been marked by a TODO comment a long time ago. The second one will have to wait a little.
U are awesome! Thx
Could you try the latest version from the git repository ? It adds support to use a thread pool in the JSON-RPC dispatcher (and server). I haven't added tests yet, as I'll do it next week.
See the server part of the readme file to setup the thread pool.
Big thx for implementing this functional! I can't do really big test with high loading for now, but simple tests work perfect! In past i have some issues with threads and mysql, and when i can i'm try to test this.
Final features implemented for this issue:
SimpleJSONRPCDispatcher.set_notification_pool()
The ThreadPool class is now tested, no need to keep this opened.
is it possible to add another "notify" method, for calling methods without waiting for completion? it will be useful for some specific things, like pushing data to server (with long processing of it, for example adding to db). I'm know, it's break specification, but can be useful like optional extended future.