On Fri, Oct 12, 2012 at 07:39:21AM +0900, FUJITA Tomonori wrote:
> On Thu, 11 Oct 2012 17:17:15 +0900
> Isaku Yamahata <[email protected]> wrote:
> 
> > Since import_module() isn't aware of cwd, so it may result in double import.
> > Avoid double import.
> 
> Elaborate how it happens, please.

I'll add the following to the commit message.

In the following example, the first one(ryu.app.event_dumper) imports the
module, ryu.app.event_dumper, relative to ryu/.., the second one
(ryu/app/event_dumper.py) imports the module, event_dumper, relative to
ryu/app. Python thinks that they are different modules.
Although it doesn't make much sense to instantiate same application twice,
I don't think of any reason to prevent it. And it is difficult to understand
what's happening.

$ PYTHONPATH=$(pwd) ./bin/ryu-manager --app_lists=ryu.app.event_dumper 
--app_lists=ryu/app/event_dumper.py
loading app ryu.controller.ofp_handler
loading app ryu.app.event_dumper
loading app ./ryu/app/event_dumper.py
Traceback (most recent call last):
  File "./bin/ryu-manager", line 81, in <module>
    main()
  File "./bin/ryu-manager", line 61, in main
    app_mgr.load_apps(FLAGS.app_lists)
  File "/ryu/base/app_manager.py", line 94, in load_apps
    cls = self.load_app(app_cls_name)
  File "/ryu/base/app_manager.py", line 74, in load_app
    mod = utils.import_module(name)
  File "/ryu/utils.py", line 34, in import_module
    __import__(name)
  File "/ryu/app/event_dumper.py", line 29, in <module>
    'list of dispatcher name to dump event: default any')
  File "/usr/lib/python2.7/dist-packages/gflags.py", line 2673, in 
DEFINE_multistring
    DEFINE_multi(parser, serializer, name, default, help, flag_values, **args)
  File "/usr/lib/python2.7/dist-packages/gflags.py", line 2660, in DEFINE_multi
    flag_values)
  File "/usr/lib/python2.7/dist-packages/gflags.py", line 2045, in DEFINE_flag
    fv[flag.name] = flag
  File "/usr/lib/python2.7/dist-packages/gflags.py", line 916, in __setitem__
    raise DuplicateFlagError(name, self)
gflags.DuplicateFlagError: The flag 'dump_queue' is defined twice. First from 
ryu.app.event_dumper, Second from event_dumper

-- 
yamahata

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to