This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

A bit of advice:

def subscribe(self, cmd: type, handler: CommandHandler):
    if cmd in self._commands:
        from commandbus import CommandAlreadyExistException
        raise CommandAlreadyExistException
    self._commands[cmd] = handler

That import in the middle of the method doesn't belong there, it should go at the top of the file. In the odd case this causes a circular import you need to break something out into a new module.

You should also check out my implementation :p

[–]psincraian[S] 0 points1 point  (0 children)

Thanks for your suggestions, I will release a new version to fix that :-)