Closed santazhang closed 10 years ago
It seems that async RPC in Python extension has some problems. For the following code, the RPC is likely never gonna be sent:
c = simplerpc.Client()
c.connect("127.0.0.1:8848)
c.async_add()
This is because after c.async_add()
, the client got immediately garbage collected, thus the underlying rpc::Client::close_and_release()
got called, which will call invalidate_pending_futures()
. This will cancel all async RPC requests.
As of commit 6fd37e1ad933843f9ab178bf9e05ff35bce82630, when running
./pyunittest.py TestRpcGen.test_timedwait
, the Server cannot shutdown, saying it's waiting for 1 alive connection to shutdown. This is not correct, because Client has already been GC'ed and from the debug log we can see that the socket has been closed.This problem can be reliably repeated. Let a client issues an RPC request which takes a long time, and let the client use timed_wait with a very short period. Then close the client before server's RPC ever finishes. The above problem will be caused.
It seems to me this problem is caused by not releasing ServerConnection correctly in
ServerConnection::close()
. There's ashould_release
flag in the code, which I suspect is not correctly set when Client is using future.timed_wait().Also it could be possible that the PollMgr did not handle socket close correctly.
I need to check if this bug happens on C++-only code as well.