nilmdb/tests
Jim Paris da72fc9777 Explicitly avoid HTTP/1.1 persistent connections (keep-alive)
We do this by creating a new requests.Session object for each request,
sending a "Connection: close" request header, and then explicitly
marking the connection for close after the response is read.

This is to avoid a longstanding race condition with HTTP keepalive
and server timeouts.  Due to data processing, capture, etc, requests
may be separated by an arbitrary delay.  If this delay is shorter
than the server's KeepAliveTimeout, the same connection is used.
If the delay is longer, a new connection is used.  If the delay is
the same, however, the request may be sent on the old connection at
the exact same time that the server closes it.  Typically, the
client sees the connection as closing between the request and the
response, which leads to "httplib.BadStatusLine" errors.

This patch avoids the race condition entirely by not using persistent
connections.

Another solution may be to detect those errors and retry the
connection, resending the request.  However, the race condition could
potentially show up in other places, like a closed connection during
the request body, not after.  Such an error could also be a legitimate
network condition or problem.  This solution should be more reliable,
and the overhead of each new connection will hopefully be minimal for
typical workloads.
2014-02-18 14:36:58 -05:00
..
data Fix tests 2013-05-09 22:27:10 -04:00
testutil Remove aplotter code 2013-03-24 21:29:09 -04:00
runtests.py Replace bare 'except:' with 'except: Exception' 2013-03-24 21:28:01 -04:00
test_bulkdata.py Rename bulkdata.append_string to bulkdata.append_data 2013-04-08 18:51:45 -04:00
test_client.py Explicitly avoid HTTP/1.1 persistent connections (keep-alive) 2014-02-18 14:36:58 -05:00
test_cmdline.py Add test for limited interval removal 2014-02-14 15:53:02 -05:00
test_interval.py Add nilmdb.utils.interval.intersection by generalizing set_difference 2013-07-30 14:48:19 -04:00
test_lrucache.py Fix lrucache decorator argspecs 2013-01-18 17:13:50 -05:00
test_mustclose.py Make test_mustclose more complete 2013-03-01 16:30:22 -05:00
test_nilmdb.py Fix tests 2013-05-09 22:27:10 -04:00
test_numpyclient.py Allow start==end in stream_insert_context, if no data was provided. 2013-04-11 13:25:37 -04:00
test_printf.py Replace bare 'except:' with 'except: Exception' 2013-03-24 21:28:01 -04:00
test_rbtree.py Huge cleanup of namespaces, modules, packages, imports. 2013-01-28 19:04:52 -05:00
test_serializer.py Remove stray print 2013-07-30 15:21:09 -04:00
test_threadsafety.py Improve serializer_proxy and verify_thread_proxy 2013-02-23 14:28:37 -05:00
test_timestamper.py Bulk of the switch to int64 microsecond timestamps, including test data. 2013-03-15 15:08:58 -04:00
test.order Add nilmdb.client.numpyclient.NumpyClient with stream_extract_numpy 2013-04-07 17:43:52 -04:00