-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
936bc47
commit 1dd3e46
Showing
1 changed file
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# <[email protected]> | ||
# Etienne Pelletier <[email protected]> | ||
# | ||
# Copyright (c) 2021 Tom Kralidis | ||
# Copyright (c) 2025 Tom Kralidis | ||
# Copyright (c) 2024 Louis-Philippe Rousseau-Lambert | ||
# Copyright (c) 2024 Etienne Pelletier | ||
# | ||
|
@@ -31,6 +31,7 @@ | |
# OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
# ================================================================= | ||
|
||
import logging | ||
|
||
from sarracenia.flowcb import FlowCB | ||
|
@@ -40,17 +41,18 @@ | |
|
||
class EventBase(FlowCB): | ||
|
||
def process_messages(self, worklist) -> bool: | ||
def process_message(self, worklist, worklist_type) -> bool: | ||
""" | ||
Process messages from the worklist | ||
Process sarracenia message | ||
:param worklist: `sarracenia.flow.worklist` | ||
:returns: `bool` | ||
""" | ||
|
||
for msg in worklist.incoming: | ||
new_msgs = [] | ||
|
||
for msg in getattr(worklist, worklist_type): | ||
try: | ||
from msc_pygeoapi.handler.core import CoreHandler | ||
|
||
|
@@ -59,11 +61,14 @@ def process_messages(self, worklist) -> bool: | |
handler = CoreHandler(filepath) | ||
result = handler.handle() | ||
LOGGER.debug(f'Result: {result}') | ||
new_msgs.append(msg) | ||
except Exception as err: | ||
LOGGER.error(f'Error handling message: {err}') | ||
worklist.failed.append(msg) | ||
return False | ||
|
||
setattr(worklist, worklist_type, new_msgs) | ||
|
||
return True | ||
|
||
|
||
|
@@ -77,7 +82,8 @@ def after_work(self, worklist) -> None: | |
:returns: `bool` | ||
""" | ||
return self.process_messages(worklist) | ||
|
||
return self.process_message(worklist, 'ok') | ||
|
||
|
||
class EventAfterAccept(EventBase): | ||
|
@@ -90,4 +96,5 @@ def after_accept(self, worklist) -> None: | |
:returns: `bool` | ||
""" | ||
return self.process_messages(worklist) | ||
|
||
return self.process_message(worklist, 'incoming') |