async def dispatch_event(self, event):
log.debug('<STR_LIT>'.format(event.__class__.__name__, len(self.hooks)))<EOL>for hook in self.hooks:<EOL><INDENT>try:<EOL><INDENT>if asyncio.iscoroutinefunction(hook):<EOL><INDENT>await hook(event)<EOL><DEDENT>else:<EOL><INDENT>hook(event)<EOL><DEDENT><DEDENT>except Exception as e:  <EOL><INDENT>log.warning(<EOL>'<STR_LIT>'.format(hook.__name__, str(e)))<EOL><DEDENT><DEDENT>if isinstance(event, (TrackEndEvent, TrackExceptionEvent, TrackStuckEvent)) and event.player:<EOL><INDENT>await event.player.handle_event(event)<EOL><DEDENT>
Dispatches an event to all registered hooks.