Hi Yikai,

Could you share the command you invoked?
If "xx/service.py" is specified by handler.register_service(), you don't
need to add it for "ryu-manager" argument, I guess.
In that case, "xx/service.py" should be automatically detected as the
required service.
If specified, "xx/service.py" will be loaded doubly, then will raise
AssertionError at "assert app.name not in SERVICE_BRICKS".

# NG --> "xx/service.py" will be loaded doubly
$ ryu-manager test-xx.py xx/service.py

# OK
$ ryu-manager test-xx.py

Thanks,
Iwase


On 2017年05月19日 10:10, Yikai Lin wrote:
> And regarding the first problem, my PYTHONPATH is like this /path/to/myapp
> 
> and the service.py is at /path/to/myapp/xx/service.py
> 
> in event.py I wrote handler.register_service(‘xx.service’)
> in api.py I wrote app_manager.require_app(‘xx.service’, api_style=True)
> 
> and the output was like this:
> 
> loading app test-xx.py
> require_app: xx.service is required by test-xx
> *loading app xx/service.py*
> *loading app xx.service*
> *instantiating app xx/service.py of Service*
> *instantiating app xx.service of Service*
> Traceback (most recent call last):
>   File "/home/yikai/.local/bin/ryu-manager", line 11, in <module>
>     sys.exit(main())
>   File "/home/yikai/.local/lib/python2.7/site-packages/ryu/cmd/manager.py", 
> line 81, in main
>     services.extend(app_mgr.instantiate_apps(**contexts))
>   File 
> "/home/yikai/.local/lib/python2.7/site-packages/ryu/base/app_manager.py", 
> line 509, in instantiate_apps
>     self._instantiate(app_name, cls, *args, **kwargs)
>   File 
> "/home/yikai/.local/lib/python2.7/site-packages/ryu/base/app_manager.py", 
> line 496, in _instantiate
>     register_app(app)
>   File 
> "/home/yikai/.local/lib/python2.7/site-packages/ryu/base/app_manager.py", 
> line 62, in register_app
>     assert app.name not in SERVICE_BRICKS
> AssertionError
> 
> The bolded lines are what confuse me and where the errors come from
> 
> Yikai
> 
>> On May 18, 2017, at 1:03 PM, Yikai Lin <[email protected] 
>> <mailto:[email protected]>> wrote:
>>
>> Hi Iwase,
>>
>> I did actually enable --verbose and saw that the service was loaded, and I 
>> was able to see the first request processed. The second request however was 
>> lost.
>>
>> The test app looks something like this:
>>
>> from xxx import api
>>
>> def __init__(...):
>>     hub.spawn(_test)
>>
>> def _test(...):
>>     rep = api.getsomething(a,b)
>>     print(rep) # success
>>     rep = api.getsomethingelse(a,b)
>>     print(rep) # failure
>>
>>
>> On Wed, May 17, 2017 at 9:13 PM Iwase Yusuke <[email protected] 
>> <mailto:[email protected]>> wrote:
>>
>>     Hi Yikai,
>>
>>     Sorry if I couldn't understand your question well.
>>
>>
>>     On 2017年05月17日 15:20, Yikai Lin wrote:
>>     > The first problem was somehow fixed by removing xxx from that line of 
>> code, so it goes handler.register_service('service)', which is weird. But 
>> the second problem was not resolved.
>>
>>     The arguments of handler.register_service() is the string which is the 
>> "Python module path"
>>     from your current "sys.path".
>>     For example, if you set PYTHONPATH=/path/to/yourapp and service is 
>> placed at
>>     /path/to/yourapp/service.py, you need to specify just "service" to 
>> register_service.
>>
>>     For the second problem, if you got "EVENT LOST", this messages shows 
>> your application or
>>     service were not loaded as expected.
>>     Please confirm the dump of services at starting of ryu-manager with 
>> "--verbose" option.
>>     e.g.)
>>     $ ryu-manager --verbose ryu/app/simple_switch_13.py
>>     Registered VCS backend: git
>>     Registered VCS backend: hg
>>     Registered VCS backend: svn
>>     Registered VCS backend: bzr
>>     loading app ryu/app/simple_switch_13.py
>>     loading app ryu.controller.ofp_handler
>>     instantiating app ryu/app/simple_switch_13.py of SimpleSwitch13
>>     instantiating app ryu.controller.ofp_handler of OFPHandler
>>     BRICK ofp_event
>>       PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13': {'config'}}
>>       PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': {'main'}}
>>       CONSUMES EventOFPSwitchFeatures
>>       CONSUMES EventOFPHello
>>       CONSUMES EventOFPPortStatus
>>       CONSUMES EventOFPEchoRequest
>>       CONSUMES EventOFPErrorMsg
>>       CONSUMES EventOFPPortDescStatsReply
>>       CONSUMES EventOFPEchoReply
>>     BRICK SimpleSwitch13
>>       CONSUMES EventOFPSwitchFeatures
>>       CONSUMES EventOFPPacketIn
>>
>>     Thanks,
>>     Iwase
>>
>>
>>     >
>>     > On Wed, May 17, 2017 at 2:15 AM Yikai Lin <[email protected] 
>> <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> 
>> wrote:
>>     >
>>     >     Hi,
>>     >
>>     >     I was trying to wrote an "topology" like service app that exposes 
>> APIs for other applications. So I started from mimicing the topology app, 
>> and I created the api.py, event.py and the main file service.py. I have 
>> another test program that basically calls the api and sends several 
>> sequential requests to the service app and it basically just returns a reply 
>> for the test program to print out. I ran into some issues:
>>     >
>>     >     1. I didn't put the codes under ryu's folder, I actually added my 
>> project path and tried to run from there, but if I added 
>> "handler.register_service('myapp.xxx.service')" to event.py, ryu-manager 
>> tried to load two services xxx/service and xxx.service and it couldn't find 
>> the latter
>>     >     2. If I didn't put that code in event.py, the two apps can run, 
>> but only the first request was received and replied, after which an "event 
>> lost" was reported. I didn't spawn any new threads in the service.py, just a 
>> bunch of functions with decorators.
>>     >
>>     >     So my questions will be, what will be a nice way to write a 
>> low-level service app and where should I place them(if that matters)? And 
>> what is the right way to implement that service app?
>>     >
>>     >     Thanks a lot
>>     >     Yikai
>>     >
>>     >
>>     >
>>     > 
>> ------------------------------------------------------------------------------
>>     > Check out the vibrant tech community on one of the world's most
>>     > engaging tech sites, Slashdot.org <http://Slashdot.org>! 
>> http://sdm.link/slashdot
>>     >
>>     >
>>     >
>>     > _______________________________________________
>>     > Ryu-devel mailing list
>>     > [email protected] 
>> <mailto:[email protected]>
>>     > https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>     >
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to