basho / riak-python-client

The Riak client for Python.
Apache License 2.0
321 stars 183 forks source link

Stop all pools when shutting down. #488

Closed lukebakken closed 8 years ago

lukebakken commented 8 years ago

Incorporates #487

lukebakken commented 8 years ago

@linkdd - thanks for the PR. Could you please run this command in your environment? The command assumes that Riak is running on localhost.

The test suite locks up when I run it. CTRL-C doesn't work, either, I have to background the process and kill -9 it. I am using Python 2.7.11

Command:

RIAK_TEST_HOST=localhost RIAK_TEST_PB_PORT=8087 RUN_CLIENT=1 python -m unittest --verbose riak.tests.test_client

Output I get:

$ RIAK_TEST_HOST=localhost RIAK_TEST_PB_PORT=8087 RUN_CLIENT=1 python -m unittest --verbose riak.tests.test_client
test_can_set_tcp_keepalive (riak.tests.test_client.ClientTests) ... ok
test_multiget_bucket (riak.tests.test_client.ClientTests) ... ok
test_multiget_errors (riak.tests.test_client.ClientTests) ... ok
test_multiget_notfounds (riak.tests.test_client.ClientTests) ... ok
test_multiget_pool_size (riak.tests.test_client.ClientTests) ... ok
test_multiput_errors (riak.tests.test_client.ClientTests) ... ok
test_multiput_pool_options (riak.tests.test_client.ClientTests) ... ok
test_multiput_pool_size (riak.tests.test_client.ClientTests) ... ok
test_pool_close (riak.tests.test_client.ClientTests) ... skipped 'RUN_POOL is 0'
test_request_retries (riak.tests.test_client.ClientTests) ... ok
test_request_retries_configurable (riak.tests.test_client.ClientTests) ... ok
test_timeout_validation (riak.tests.test_client.ClientTests) ... ok
test_uses_client_id_if_given (riak.tests.test_client.ClientTests) ... ok

----------------------------------------------------------------------
Ran 13 tests in 0.054s

OK (skipped=1)
^C^C^C^C^Z
[1]+  Stopped                 RIAK_TEST_PB_PORT=8087 RUN_CLIENT=1 python -m unittest --verbose riak.tests.test_client
lbakken@brahms ~/Projects/basho/riak-python-client (fixes/lrb/stop-pools-gh-449 *=)
$ kill -9 %1
[1]+  Killed                  RIAK_TEST_PB_PORT=8087 RUN_CLIENT=1 python -m unittest --verbose riak.tests.test_client
lbakken@brahms ~/Projects/basho/riak-python-client (fixes/lrb/stop-pools-gh-449 *=)
$ python --version
Python 2.7.11
lukebakken commented 8 years ago

I added debugging in 9fca06c741a249fceb26259862a8d13b63e9906e

You can see that the worker threads will never consider themselves stopped as they are all waiting on an item in the queue. Adding a timeout should resolve this, adding it now.