implement __eq__ and __hash__ for workers

main
Travis Johnson 10 years ago
parent de72f98fbe
commit c301369c2e

@ -580,6 +580,14 @@ class Worker(object):
"""Pops the latest exception handler off of the exc handler stack.""" """Pops the latest exception handler off of the exc handler stack."""
return self._exc_handlers.pop() return self._exc_handlers.pop()
def __eq__(self, other):
if not isinstance(other, self.__class__):
raise TypeError('Cannot compare workers to other types (of workers)')
return self.name == other.name
def __hash__(self):
return hash(self.name)
class SimpleWorker(Worker): class SimpleWorker(Worker):
def _install_signal_handlers(self, *args, **kwargs): def _install_signal_handlers(self, *args, **kwargs):

Loading…
Cancel
Save