improve multiprocessing usage in process.py
improve multiprocessing usage in process.py

Some issues arose after processing reports for many tasks. This commit
hopefully fixes some issues but also improves the throughput that
process.py is able to provide.

Before it seemed that tasks were added to the pool on a one-by-one
basis. We introduce a queue threshold of 128, which in effect means that
every time the number of pending tasks drops below 128, up to another
128 are added. Not like it matters too much, but this somewhat reduces
the amount of sql queries done for selecting new tasks.

We also move some database logic (i.e., the only database query that is
directly done from within the process function) from the worker process
to the main process as a start to move all sql queries to the main
process, at some point.

cuckoobox/cuckoo,cuckoobox/cuckoo,cuckoobox/cuckoo,cuckoobox/cuckoo,cuckoobox/cuckoo