Avatar ·

How to make a Python program run in the background? [closed]

📁 question

. Answers to this question are not currently being accepted.

 

Want to improve this question? so that it can be answered with facts and citations.

Closed 3 years ago.

There is a program that does a decent job with relatively small numbers, but when the numbers increase, the program consumes all memory and hurts my processor.

I want to rewrite the program so that it stores objects in a database and performs actions on objects in the background. At the same time, I want to limit the resources consumed by the program.

Avatar ·

Random element from sequence

uses a cryptographically-insecure PRNG in Python, so if you use it in a context where it is undesirable for the result of consecutive calls to be guessable, for example when generating passwords, you should use a CSPRNG such as random.SystemRandom(), which uses OS-provided capabilities:

#!/usr/bin/env python3import randomrandom_item = random.SystemRandom().choice(["Civilian", "Mafia"])

See also: the secrets module available since Python 3.6 -- its method is exactly for SystemRandom

Log in to leave an answer

Blogs