Lock when adding to __operations_by_peer
Description
return len([peer for peer, names in operations_by_peer.items()
RuntimeError: dictionary changed size during iteration
This change allows locking when adding to __operations_by_peer
dictionary in the scheduler, instead of when only deleting.