application api & performance questions

#1

Hi,

I need to do python cli script to call a rpc on using autobahn server app,

and using the application API

My client script is really slow to do a simple task

my server code

#!/usr/bin/env python

-- coding: utf-8 --

import six

import datetime

from autobahn.twisted.wamp import Application

app = Application(‘demo’)

@app.register(‘demo.utcnow’)

def utcnow():

print(“Someone is calling me;)”)

now = datetime.datetime.utcnow()

return six.u(now.strftime("%Y-%m-%dT%H:%M:%SZ"))

if name == “main”:

app.run(url=u"ws://127.0.0.1:10001/", realm = u"realm1", standalone = True)

``

10 lines of code

the client

#!/usr/bin/env python

-- coding: utf-8 --

import six

import datetime

from autobahn.twisted.wamp import Application

import time

app = Application(‘demo’)

@app.signal(‘onjoined’)

def _():

print “application joinied”

now = yield app.session.call(‘demo.utcnow’)

print now

print(“why %s seconds to execute a simple RPC” % time.time() - start_time)

app.session.leave()

print ‘why not leaving?’

if name == “main”:

start_time = time.time()

app.run(url=u"ws://127.0.0.1:10001/", realm = u"realm1")

``

the result

22:01:32.123072

Running on ws://127.0.0.1:10001/ …

application joinied

2014-10-21T20:01:41Z

22:01:41.262541

why not leaving?

``

  1. 9 secondes to execute the call?!
  2. the session is not leaving
    What i am doing wrong?
0 Likes

#2

I don’t know what’s wrong. But, I copied both server and client, and I get a stack trace when trying to run the client. What version of autobahn are you using?

./client.py

Running on ws://127.0.0.1:10001/ …

Unhandled error in Deferred:

Unhandled Error

Traceback (most recent call last):

File “./client.py”, line 18, in

app.run(url=u"ws://127.0.0.1:10001/", realm = u"realm1")

File “/usr/local/lib/python2.7/dist-packages/autobahn-0.9.1-py2.7.egg/autobahn/twisted/wamp.py”, line 394, in run

runner.run(self.call, start_reactor)

File “/usr/local/lib/python2.7/dist-packages/autobahn-0.9.1-py2.7.egg/autobahn/twisted/wamp.py”, line 233, in run

server.listen(transport_factory)

File “/usr/lib/python2.7/dist-packages/twisted/internet/endpoints.py”, line 463, in listen

interface=self._interface)

— —

File “/usr/lib/python2.7/dist-packages/twisted/internet/defer.py”, line 110, in execute

result = callable(*args, **kw)

File “/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py”, line 495, in listenTCP

p.startListening()

File “/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py”, line 980, in startListening

raise CannotListenError(self.interface, self.port, le)

twisted.internet.error.CannotListenError: Couldn’t listen on any:10001: [Errno 98] Address already in use.

application joinied

-g

···

On Tuesday, October 21, 2014 3:07:57 PM UTC-5, Icham Achtir wrote:

Hi,

I need to do python cli script to call a rpc on using autobahn server app,

and using the application API

My client script is really slow to do a simple task

my server code

#!/usr/bin/env python

-- coding: utf-8 --

import six

import datetime

from autobahn.twisted.wamp import Application

app = Application(‘demo’)

@app.register(‘demo.utcnow’)

def utcnow():

print(“Someone is calling me;)”)

now = datetime.datetime.utcnow()

return six.u(now.strftime("%Y-%m-%dT%H:%M:%SZ"))

if name == “main”:

app.run(url=u"ws://127.0.0.1:10001/", realm = u"realm1", standalone = True)

``

10 lines of code

the client

#!/usr/bin/env python

-- coding: utf-8 --

import six

import datetime

from autobahn.twisted.wamp import Application

import time

app = Application(‘demo’)

@app.signal(‘onjoined’)

def _():

print “application joinied”

now = yield app.session.call(‘demo.utcnow’)

print now

print(“why %s seconds to execute a simple RPC” % time.time() - start_time)

app.session.leave()

print ‘why not leaving?’

if name == “main”:

start_time = time.time()

app.run(url=u"ws://127.0.0.1:10001/", realm = u"realm1")

``

the result

22:01:32.123072

Running on ws://127.0.0.1:10001/

application joinied

2014-10-21T20:01:41Z

22:01:41.262541

why not leaving?

``

  1. 9 secondes to execute the call?!
  2. the session is not leaving
    What i am doing wrong?
0 Likes