Opened 17 years ago
Closed 16 years ago
#1364 enhancement closed invalid (invalid)
[PATCH] re-installation of the same reactor
Reported by: | antony | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Keywords: | |
Cc: | itamarst, antony | Branch: | |
Author: |
Description
Attachments (1)
Change History (10)
Changed 17 years ago by
comment:2 Changed 17 years ago by
You probably don't want to intall the reactor in two different modules though. Reactor installation is typically the job of the control script (e.g. twistd), whichever piece of code eventually calls reactor.run(). Maybe someone will want to use parts of your package with a different reactor; you shouldn't have library code installing the reactor.
comment:3 Changed 17 years ago by
Well, I still see no reason to raise an exception in a situation that causes no problem. Your use of the word "typically" indicates that other scenarios *may* be valid, and the current implementation needlessly prevents them. More to the point (or possibly less so), my situation is not of library code installing the reactor. It the case of a GUI service that may be run as part of a larger application, but I also want it to be runnable by simply executing the main module, using the """if __name__ == "__main__":""" idiom. This requires the wxreactor to be installed, but the reactor is imported at the top of the script, so I would rather install it there, but in case I use a control script to bundle it up in a larger application, this would raise the AssertionError. I think it's a pretty legitimate scenario, and even if it's not ideal coding, I don't see why it should be disallowed altogether. Anyway, what I said in the previous paragraph probably applies to other situations as well.
comment:4 Changed 17 years ago by
Possibly. Your patch is probably insufficient though - for one thing, it doesn't check that it's the same reactor (what happens if someone installs both gtk2 and wx reactors? One of them will be silently ignored, masking the bug for a while.) Also, creating a reactor instance can have side effects inside the low-level GUI event loop which means you can't create the object twice. So the correct thing to do is check that installed reactor is the same as one you are attempting to install, if it is the same do not create 2nd reactor instance at all, if it is different complain.
comment:6 Changed 17 years ago by
It doesn't - notice that by the time you his this function the second reactor instance has already been created.
comment:8 Changed 16 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:9 Changed 11 years ago by
Note: See
TracTickets for help on using
tickets.