Skip to content

Commit

Permalink
Make event queueing non-async
Browse files Browse the repository at this point in the history
Make sure all events are queued before handling the next line
  • Loading branch information
linuxdaemon committed Jun 1, 2020
1 parent bb7d26b commit 69528c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change user lookup logic in last.fm plugin
- Refactor minecraft_ping plugin for updated mcstatus library
- Expand youtube.py error information
- Make event queueing happen non-async
### Fixed
- Ensure event order is deterministic
- Fix matching exception in horoscope test
Expand Down
9 changes: 3 additions & 6 deletions cloudbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def load_clients(self):
scanner = Scanner(bot=self)
scanner.scan(clients, categories=['cloudbot.client'])

async def process(self, event):
def process(self, event):
"""
:type event: Event
"""
Expand Down Expand Up @@ -397,8 +397,5 @@ def add_hook(hook, _event):

tasks.sort(key=lambda t: t[0].priority)

# Run the tasks
await asyncio.gather(*[
asyncio.ensure_future(self.plugin_manager.launch(hook, _event))
for hook, _event in tasks
], loop=self.loop)
for _hook, _event in tasks:
async_util.wrap_future(self.plugin_manager.launch(_hook, _event))
4 changes: 2 additions & 2 deletions cloudbot/clients/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ def data_received(self, data):
self.conn.name, line, self.conn.describe_server()
)
else:
# handle the message, async
async_util.wrap_future(self.bot.process(event), loop=self.loop)
# handle the message
self.bot.process(event)

def parse_line(self, line: str) -> Event:
message = Message.parse(line)
Expand Down

0 comments on commit 69528c7

Please sign in to comment.