Permalink
Browse files

container class is now a singleton and agents use it transparently.

  • Loading branch information...
javipalanca committed Oct 1, 2018
1 parent 4bae3ba commit 6eef9aea51b97f9b2b41c2ed4c958f5276323b3d
Showing with 11 additions and 2 deletions.
  1. +1 −0 requirements.txt
  2. +7 −2 spade/agent.py
  3. +3 −0 spade/container.py
View
@@ -5,3 +5,4 @@ aiohttp_jinja2>=0.14.0
jinja2>=2.9.6
jinja2-time==0.2.0
timeago==1.0.8
singletonify==0.2.3
View
@@ -10,6 +10,7 @@
import aioxmpp.ibr as ibr
from aioxmpp.dispatcher import SimpleMessageDispatcher
from spade.container import Container
from spade.message import Message
from spade.presence import PresenceManager
from spade.trace import TraceStore
@@ -24,7 +25,7 @@ class AuthenticationFailure(Exception):
class Agent(object):
def __init__(self, jid, password, verify_security=False, loop=None):
def __init__(self, jid, password, verify_security=False, use_container=True, loop=None):
"""
Creates an agent
@@ -41,7 +42,11 @@ def __init__(self, jid, password, verify_security=False, loop=None):
self.behaviours = []
self._values = {}
self.container = None
if use_container:
self.container = Container()
self.container.register(self)
else:
self.container = None
self.traces = TraceStore(size=1000)
View
@@ -1,4 +1,7 @@
from singletonify import singleton
@singleton()
class Container(object):
def __init__(self):
self.__agents = {}

0 comments on commit 6eef9ae

Please sign in to comment.