Re: [Python-Dev] [Twisted-Python] Newbie question

On 9/7/06, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Thu, 7 Sep 2006 11:41:48 -0400, Timothy Fitz <timothyfitz@gmail.com> wrote:
Why don't the reactors throw if this happens? This question comes up almost once a month.
One could just as easily ask why no one bothers to read mailing list archives to see if their question has been answered before.
Let me rephrase. Are there any technical reasons preventing reactor.run() from throwing if started twice? Is there any reason *not* to make this throw an exception? Timothy Fitz

On Thu, 7 Sep 2006 14:08:13 -0400, Timothy Fitz <timothyfitz@gmail.com> wrote:
On 9/7/06, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Thu, 7 Sep 2006 11:41:48 -0400, Timothy Fitz <timothyfitz@gmail.com> wrote:
Why don't the reactors throw if this happens? This question comes up almost once a month.
One could just as easily ask why no one bothers to read mailing list archives to see if their question has been answered before.
Let me rephrase. Are there any technical reasons preventing reactor.run() from throwing if started twice? Is there any reason *not* to make this throw an exception?
Not really. Jean-Paul

On Sep 7, 2006, at 2:25 PM, Jean-Paul Calderone wrote:
Let me rephrase. Are there any technical reasons preventing reactor.run() from throwing if started twice? Is there any reason *not* to make this throw an exception?
Not really.
It could also work. What's preventing it is that the shutdown triggers are cleared when the reactor stops, and some of the triggers are essential for the shutdown process, so the second time, it doesn't ever finish shutting down. However, even though it'd be possible to fix, perhaps it is better to simply throw an exception on the second reactor.run(), since most people who do that shouldn't actually be running the reactor twice, they just didn't know the better thing to do yet. James

On Thu, 7 Sep 2006 15:01:08 -0400, James Y Knight <foom@fuhm.net> wrote:
However, even though it'd be possible to fix, perhaps it is better to simply throw an exception on the second reactor.run(), since most people who do that shouldn't actually be running the reactor twice, they just didn't know the better thing to do yet.
I think that's a good idea. Based on the nature of the questions that I've seen, I think that this would probably be a good idea even if we *did* have a restartable reactor. Add an interface, IRestartableReactor, and require people who want to use it to call 'reactor.restart()'. While this might not actually *do* anything, the conspicuous absence of it from any example code and a potentially useful error message from reactor.run would prevent the question from being asked repeatedly...

On 9/7/06, glyph@divmod.com <glyph@divmod.com> wrote:
On Thu, 7 Sep 2006 15:01:08 -0400, James Y Knight <foom@fuhm.net> wrote:
However, even though it'd be possible to fix, perhaps it is better to simply throw an exception on the second reactor.run(), since most people who do that shouldn't actually be running the reactor twice, they just didn't know the better thing to do yet.
I think that's a good idea. Based on the nature of the questions that I've seen, I think that this would probably be a good idea even if we *did* have a restartable reactor. Add an interface, IRestartableReactor, and require people who want to use it to call 'reactor.restart()'. While this might not actually *do* anything, the conspicuous absence of it from any example code and a potentially useful error message from reactor.run would prevent the question from being asked repeatedly...
I've added this to the tracker [http://twistedmatrix.com/trac/ticket/2066], further discussion should probably be taken there.
participants (4)
-
glyph@divmod.com
-
James Y Knight
-
Jean-Paul Calderone
-
Timothy Fitz