autobahn-python icon indicating copy to clipboard operation
autobahn-python copied to clipboard

Unwanted noise

Open oddjobz opened this issue 6 years ago • 13 comments

Is there a reason why we need this as a warning?

https://github.com/crossbario/autobahn-python/blob/0b0f3262903eb879a9ab6b313ab1a77e4d525726/autobahn/twisted/component.py#L332

When starting a lot of components, it seems like unnecessary noise, could this at least be made an 'info' or maybe even a 'debug' ?

oddjobz avatar Apr 16 '19 10:04 oddjobz

Yeah, that could probably be a "info" or something instead (or, you could pass in the reactor, which is considered "better practice" really).

meejah avatar Apr 16 '19 15:04 meejah

Mmm .. on the one hand I can see why you would want to put out a warning if people "should" be supplying a reactor .. but on the other hand, if a reactor "should" be specified, maybe accepting a default isn't the right thing to do? (a warning because you've used a valid default seems a bit .. odd ?)

.. do you have an example of using "run()" and passing a reactor, I'm not seeing it on the demos?

oddjobz avatar Apr 16 '19 18:04 oddjobz

react passes the reactor: https://github.com/crossbario/autobahn-python/blob/0b0f3262903eb879a9ab6b313ab1a77e4d525726/autobahn/twisted/component.py#L379

...which then passes it on to start here: https://github.com/crossbario/autobahn-python/blob/0b0f3262903eb879a9ab6b313ab1a77e4d525726/autobahn/wamp/component.py#L931

meejah avatar Apr 16 '19 18:04 meejah

I think it might be optional because "originally" start took zero arguments? (In any case, it could probably be an info instead of a warning at least...)

meejah avatar Apr 16 '19 19:04 meejah

Sorry, not following .. examples use;

run([components])

Can't seem to find an example of this with a reactor?

oddjobz avatar Apr 16 '19 19:04 oddjobz

Yes, run doesn't take a reactor as it uses react underneath. react (and run) are supposed to be the "high level" interfaces, and handle selecting a reactor, setting up logging, etc. If you want more control, you use start() .. and then you have to select the reactor yourself and start logging yourself.

meejah avatar Apr 16 '19 19:04 meejah

Mmm, so .. if passing a reactor is "better practice" .. that sort of implies that maybe I shouldn't be using run?

oddjobz avatar Apr 16 '19 20:04 oddjobz

I think what @meejah is trying to get at is:

  • "run" is high-level API, and that chooses the best reactor automatically (*)
  • everything inside / beneath the high-level however should take a reactor argument and use that, so that essentially there is only 1 place where the reactor is chosen (*)

that being said: Twisted itself sadly doesn't follow that strictly .. asyncio (where it's "loop" rather than "reactor") is better. implicit or ad-hoc reactor imports in Twisted and Twisted based library and app code is .. a PITA sometimes. if you dig through CB/AB history/commits, you'd find a bunch of issues related to that;) it's the kinda of bug as Python2->3 change of string base type to real unicode. if python would have had it done that correctly in the first place, it would have saved the whole community decades of accumulated work to clean up later .. hah. shit happens.

oberstet avatar Apr 17 '19 03:04 oberstet

Sure .. I find Twisted in general is a lot "nosier" than I would expect. If I'm using an established library, I prefer relative silence unless something unexpected happens, or unless I explicitly ask for more information .. a dozen warnings for calling "run" seemed a little excessive .. :)

oddjobz avatar Apr 17 '19 13:04 oddjobz

Yeah, that quoted text :)

Also, asyncio doesn't get it right since there's get_default_loop() so some asyncio libraries have "pass the loop" throughout them, and some depend on "a global loop, somewhere". So it's kind of the same situation that Twisted is currently in :/

meejah avatar Apr 17 '19 15:04 meejah

You're getting those warnings just calling "run()"? (Reading the code, I'd expect that you wouldn't get the warning then, because _run() passes in the loop/reactor..?)

meejah avatar Apr 17 '19 15:04 meejah

Also, asyncio doesn't get it right since .. so it's kind of the same situation that Twisted is currently in :/

oh, I see! well, so they repeated the same mistake. well. too bad:(

oberstet avatar Apr 17 '19 19:04 oberstet

Yeah, my startup looks like this;

2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 Using default reactor
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-04-18T03:11:29+0100 connecting once using transport type "websocket" over endpoint "tcp"

oddjobz avatar Apr 18 '19 02:04 oddjobz