Skip to content

Commit

Permalink
Adding some warnings and better error messages, fixing pipeline issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcschrg committed Nov 22, 2023
1 parent f82002f commit 7a71c64
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/publish-mango.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@ on:

jobs:
deploy:
runs-on: python:3.8.10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt
pip3 install -e .
apt update
apt install --assume-yes mosquitto
service mosquitto start
sudo apt update
sudo apt install --assume-yes mosquitto
sudo service mosquitto start
pip3 install pytest
pip3 install coverage
- name: Test+Coverage
run: |
source venv/bin/activate
coverage run --source ./mango -m pytest
coverage report
- name: Build package
run: python setup.py sdist bdist_wheel
run: |
source venv/bin/activate
python setup.py sdist bdist_wheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1
with:
Expand Down
20 changes: 15 additions & 5 deletions mango/container/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def __init__(
) -> None:
self._active = False
self._container = container
self._mp_enabled = False

def _init_mp(self):
# For agent multiprocessing support
Expand All @@ -364,6 +365,7 @@ def _init_mp(self):
self._handle_process_events_tasks: List[asyncio.Task] = []
self._handle_sp_messages_tasks: List[asyncio.Task] = []
self._main_queue = None
self._mp_enabled = True

@property
def aids(self):
Expand Down Expand Up @@ -425,6 +427,8 @@ def pre_hook_send_internal_message(
return None, target_inbox

def _find_sp_queue(self, aid):
if not self._mp_enabled:
return None
for pid, aids in self._pid_to_aids.items():
if aid in aids:
return PipeToWriteQueue(self._pid_to_message_pipe[pid])
Expand Down Expand Up @@ -586,11 +590,17 @@ def _reserve_aid(self, suggested_aid=None):
if aid is not None:
return aid

if suggested_aid is None or not self.is_aid_available(suggested_aid):
aid = f"{AGENT_PATTERN_NAME_PRE}{self._aid_counter}"
self._aid_counter += 1
else:
aid = suggested_aid
if suggested_aid is not None:
if self.is_aid_available(suggested_aid):
return suggested_aid
else:
logger.warning(
"The suggested aid could not be reserved, either it is not available or it is not allowed (pattern agentX);%s",
suggested_aid,
)

aid = f"{AGENT_PATTERN_NAME_PRE}{self._aid_counter}"
self._aid_counter += 1
return aid

def register_agent(self, agent, suggested_aid: str = None):
Expand Down

0 comments on commit 7a71c64

Please sign in to comment.