I am using twisted.internet.defer
extensively in my package , I have encountered a problem which I am unable to solve after spending 2 days on it. Below is my problem scenario.
# all imports done and correct
class infrastructure: # line 1
@inlineCallbacks
def dict_service(self):
client = MyClient()
services = yield client.listServices() # line 5
ret = (dict(service.name, [cont.container_id for cont in service.instances]) for service in dockerServices)
returnValue(ret) # line 7
I am calling my client which returns me list of Services. listServices()
return type is twisted.internet.defer.ReturnValue
.
class myinterface:
# has infrastructure
def init:
data = dict(
container_services=self._infrastructure.dict_service(),
)
when executing this I get below error which I am unable to comprehend. can someone please help.
raise TypeError(repr(o) + \" is not JSON serializable\")\nexceptions.TypeError: <DeferredWithContext at 0x4bfbb48 current result: <twisted.python.failure.Failure <type 'exceptions.NameError'>>> is not JSON serializable\n"
Is it because that wrapping dict
with returnValue
creating problem?