[core.process_queue] fixed: race condition in pendig flag check

Construction "pending, self.pending = self.pending, False" is not
safe as pending flag may be set in the middle and then will be
overriten with False.