I guess this works but it was not what I originally had in mind.  The respacing of things in the github comment confused the issue.   Your original code was something like:

if jid in jobids:
....jobids[jid] += 1
else:
....jobids[jid] = 1


What I suggested was:

if jid in jobids:
....jobids[jid] += 1
else:
....jobids[jid] = 1
....if len(jobids) > 1:
........break

That way you do not keep looping through this code once we know that all the jobids are not the same.