Move self.emit outside of the try block