lmacken / quantumrandom

Tools for utilizing the ANU Quantum Random Number Generator
https://pypi.python.org/pypi/quantumrandom
146 stars 36 forks source link

v1.9.0 Random subclass, fetch timeout #22

Open calebj opened 5 years ago

calebj commented 5 years ago

Adds a subclass of random.Random that pulls from the ANU QRN server. It defaults to caching 1kb of raw binary data, and automatically fetches more on demand, or in the background when less than 64 bytes of random data remain. These parameters can be adjusted in the QuantumRandom constructor: caching can be disabled by specifying cached_bytes = None, and auto-fetching disabled with autofetch_at = None.

get_data() also has a new parameter timeout, which is passed directly to urlopen(), and the other data-retrieving functions will pass their kwargs through so that timeout can be specified in any of them.

Missing until the base idea is greenlit: