Update consensus.py

make the num_cores can be customed.