Skip to content

Commit

Permalink
Remove unused run_before_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Jun 1, 2020
1 parent 5893762 commit 980f5af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ 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
- Ensure event order is deterministic
### Fixed
- Ensure event order is deterministic
- Fix matching exception in horoscope test
- Fix youtube.py ISO time parse
- Fix grammatical error in food sentence (beer)
Expand All @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix FML random URL
### Removed
- twitch.py removed due to outdated API and lack of maintainer
- Remove unused run_before events/tasks

## [1.3.0] 2020-03-17
### Added
Expand Down
13 changes: 3 additions & 10 deletions cloudbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,10 @@ async def process(self, event):
"""
:type event: Event
"""
run_before_tasks = []
tasks = []
halted = False

def add_hook(hook, _event, _run_before=False):
def add_hook(hook, _event):
nonlocal halted
if halted:
return False
Expand All @@ -313,10 +312,7 @@ def add_hook(hook, _event, _run_before=False):
return True

coro = self.plugin_manager.launch(hook, _event)
if _run_before:
run_before_tasks.append(coro)
else:
tasks.append(coro)
tasks.append(coro)

if hook.action is Action.HALTALL:
halted = True
Expand All @@ -329,9 +325,7 @@ def add_hook(hook, _event, _run_before=False):

# Raw IRC hook
for raw_hook in self.plugin_manager.catch_all_triggers:
# run catch-all coroutine hooks before all others - TODO: Make this a plugin argument
run_before = not raw_hook.threaded
if not add_hook(raw_hook, Event(hook=raw_hook, base_event=event), _run_before=run_before):
if not add_hook(raw_hook, Event(hook=raw_hook, base_event=event)):
# The hook has an action of Action.HALT* so stop adding new tasks
break

Expand Down Expand Up @@ -403,5 +397,4 @@ def add_hook(hook, _event, _run_before=False):
break

# Run the tasks
await asyncio.gather(*run_before_tasks, loop=self.loop)
await asyncio.gather(*tasks, loop=self.loop)

0 comments on commit 980f5af

Please sign in to comment.