drbrain / net-http-persistent

Thread-safe persistent connections with Net::HTTP
http://seattlerb.rubyforge.org/net-http-persistent
339 stars 117 forks source link

shutdown in all threads #1

Closed tosch closed 14 years ago

tosch commented 14 years ago

Hello,

I'm a contributor to the ruote project. jmettraux, the maintainer, had some issues (connections kept beeing open) when testing ruote-couch, a storage adapter for ruote, when using net-http-persistent for connecting to the couch.

jmettraux solved this by doing some monkey patching: http://github.com/jmettraux/rufus-jig/blob/master/lib/rufus/jig/adapters/net_persistent.rb#L32-75

So, as you can see, the problem is not within net-http-persistent itself, but it would be helpful to have a helper method around which shuts down all connections in all threads. I agreed to prepare a patch for net-http-persistent so that we may drop the monkey patching.

Hope you like it, any comments are appreciated.

Cheers, Torsten

drbrain commented 14 years ago

I applied this with the following modifications:

Reworked the tests to be more reliable.

Added doom-and-gloom warnings about closing connections for other threads. I'm sure somebody will have unreasonable expectations about how it is supposed to work.

This is now released as 1.4