Set default timeout for HTTP requests
Calls for requests.get etc could do with a timeout= arg set. Requests doesn't set one by default so it allows for HTTP requests to hang for an infinitely long time in some cases - the web server has to drop the TCP connection. We're lucky that nginx on nucleus.noc.ac.uk is doing that (when the CB API doesn't respond with any HTTP headers) but with a different configuration it wouldn't. This will surface bugs where the CB appears not to be receiving messages and there are no errors logged about it.
I think a sensible default is 30 seconds but make this configurable e.g. in the adapter initialization args.
Desired behaviour / for testing:
- Start up a local comms backbone
- Connect python adapter to it
docker pause <comms backbone API container name>- Do
adapter.poll() - The
poll()call should raise an Exception after seconds
Bonus points: Wrap the comms backbone API requests in a requests.Session with the timeout set on the session. The session will also do things like connection pooling which means frequent polling of the backbone will re-use the same TCP connection (bit more efficient).