twisted - WAMP with Django App using Python 2.7 AND 3.4 - is it possible? -


the essence of question is: possible use wamp notifications in django application supporting both python 2.7 , 3.4, considering code should running , interrupted if remote procedure call made? (that is, it's not waiting rpc come)

how want use wamp: program has javascript frontend python/django backend. 1 of things start function in backend when button in frontend clicked. takes time though, allow user cancel clicking button. 1 makes remote procedure call, cause function stop earlier (it changes variable checked in function). there might other needs rpc or pub/sub in future too.

we got working python 2.7 using autobahn_sync module, uses twisted, hasn't yet been ported python 3.x. that's why need way of getting our wamp notification work on 3.x.

asyncio supported , crossbar documentation seemed used instead of twisted, can't work without blocking code should running in parallel (code added below). , there doesn't seem autobahn_sync using asyncio instead of twisted.

we're new wamp , there might we're missing.

here's code (with python 3.4) we're testing using asyncio. it's blocking rest of function:

from asyncio import coroutine, new_event_loop, set_event_loop autobahn.asyncio.wamp import applicationsession, applicationrunner  class mycomponent(applicationsession):         @wamp.register("com.function.cancel")         def cancel(self):             print("called cancel procedure")             # things here             return "canceled"          @coroutine         def onjoin(self, details):             res = yield self.register(self)             print("{} procedures registered.".format(len(res)))  def function_triggered_in_frontend():     loop = new_event_loop()     set_event_loop(loop)     runner = applicationrunner(url=u"ws://localhost:8080/ws", realm=u"realm1")     runner.run(mycomponent)     # , function should continue working on other things, does't because doesn't return runner.run().     print("do stuff") 

how can register topic , return runner.run call? in python 2.7 test, autobahn_sync do:

from autobahn_sync import register, run, alreadyrunningerror @register('com.function.cancel') def cancel_generate_jobs():     print("called cancel procedure")     @register('com.function.cancel')     # def cancel_generate_jobs():  def function_triggered_in_frontend():     try:         run(realm=u"realm1")     except alreadyrunningerror:         logger.info('autbahnsync instance started.')     # , code continue being processed here, want 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -