Requests is great. But if you’ve ever used it you may have encountered a problem with your app hanging for seemingly no reason.

(If you haven’t encountered that, then you will at some point, and it may well cause you serious pain)

The cause is very simple, yet non obvious, and it lies hidden at the bottom of the quickstart documentation:

You can tell Requests to stop waiting for a response after a given number of seconds with the timeout parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely

Yes, the default timeout for a request is infinity

I’m sure there is some logic behind this, but really this should be at the top of the page in bright red flashing letters. So here it is in bright red flashing letters


To avoid problems, then, we should set an appropriate timeout value on all requests

connect_timeout=31 # number of seconds to wait for connection to be established
read_timeout=5 # maximum number of seconds between data reads

r = requests.get('', timeout=(connect_timeout, read_timeout))

Site migration in progress (Wordpress->Jekyll). Things may break.


‘Cos things break, don’t they?

Python script for “Arduino compatible” geiger counter on Raspberry Pi - outputs to Collectd format

Run with Collectd “exec” plugin

Requires RPi.GPIO:

sudo apt-get install python-rpi.gpio

Connect interrupt pin of Geiger counter to GPIO12 of RPi (configurable in script)

May need to run as root if /dev/gpiomem not available

Used with a Collectd frontend such as Collectd Graph Panel for fancy graphs:


In this post you’ll find my windows builds of rtl_sdr. The first link is the main branch and this is probably what most people will want. The other links are for keenerd’s experimental branch of rtl-sdr with additional features and the mutability branch - allows direct sampling without a hardware mod - “very experimental - probably broken” according to the author.

Download: rtl_sdr windows 32 bit binaries (03/01/2016) rtl_sdr windows 64 bit binaries (03/01/2016)

Experimental builds: rtl_sdr keenerd branch windows 32 bit binaries (04/06/2015) rtl_sdr mutability branch windows 32 bit binaries (19/06/2015)

Kalibrate-rtl is a program that can scan for GSM base stations and use them to calculate the local oscillator frequency offset (ppm error) of an RTL2832 USB dongle.

I finally got this to build after a lot of trial and error with MSYS/MinGW. As often, not that complicated, just a case of building the libraries and configuring paths correctly. Also, there was a dependency on the POSIX library librt, which doesn’t exist in MinGW.

Download here: kalibrate-rtl windows 32 bit build 05/06/2015

Run like this:

kal.exe -g 35 -s EGSM

-g sets the gain. 35 is probably a good choice -s tells kalibrate-rtl to scan for mobile base stations. Band can be GSM850, GSM-R, GSM900, EGSM, DCS, PCS

kalibrate-rtl usage on windows

Once you’ve found a channel, run kal.exe again like this:

kal.exe -g 35 -c 117

Again, -g is the gain. -c is the number of the channel you want to use for calibration. After a few seconds you should have a ppm figure for your dongle:

kalibrate-rtl ppm calculation

I recommend using the dongle normally for half an hour or so before trying to calibrate, as the ppm figure will change as the dongle warms up. It should stabilise after a while.

Here I obtained 39.4 ppm, very close to my previous manually estimated figure of 40 ppm, only much quicker to obtain.

For rtl_433/rtl-sdr builds see my previous post