librelist archives

« back to archive

run_simple's reloader logic

run_simple's reloader logic

From:
Mark Grey
Date:
2012-11-29 @ 18:05
The flask/werkzeug reloader is pretty much the coolest thing that has ever
happened to my web development.

I am writing another service with twisted and was wondering where to begin
looking in the Werkzeug internals to possibly use a similar approach to
reloading and restarting my Twisted server automatically while it is in
development.  Any pointers or tips would be appreciated!

Re: [flask] run_simple's reloader logic

From:
Ned Jackson Lovely
Date:
2012-11-29 @ 18:28
On Thu, Nov 29, 2012 at 1:05 PM, Mark Grey <mark.asperia@gmail.com> wrote:
> I am writing another service with twisted and was wondering where to begin
> looking in the Werkzeug internals to possibly use a similar approach to
> reloading and restarting my Twisted server automatically while it is in
> development.  Any pointers or tips would be appreciated!

https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L489

-- 
njl

Re: [flask] run_simple's reloader logic

From:
Mark Grey
Date:
2012-11-29 @ 19:34
Oh man, that did the charm something serious.  Very cool.

Just for the the benefit of posterity, if you use this with twisted you
need to make sure you call to reactor.run() passes kwarg
installSignalHandlers=0, so the threading signals check out correctly.

On Thu, Nov 29, 2012 at 1:28 PM, Ned Jackson Lovely <njl@njl.us> wrote:

> On Thu, Nov 29, 2012 at 1:05 PM, Mark Grey <mark.asperia@gmail.com> wrote:
> > I am writing another service with twisted and was wondering where to
> begin
> > looking in the Werkzeug internals to possibly use a similar approach to
> > reloading and restarting my Twisted server automatically while it is in
> > development.  Any pointers or tips would be appreciated!
>
> https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L489
>
> --
> njl
>

Re: [flask] run_simple's reloader logic

From:
Yaniv Aknin
Date:
2012-11-30 @ 06:56
If we're writing for posterity, I suggest noting you should use
installSignalHandlers=0 only during development and only if you understand
the consequences.
Several twisted patterns I can think of benefit from well programmed

reactor.stop()<http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorCore.html#stop>rather
than

reactor.crash()<http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorCore.html#crash>-
without any signal handlers, you're effectively crashing the reactor
on
reception of many signals, including the common INT and TERM.

 - Yaniv


On Thu, Nov 29, 2012 at 9:34 PM, Mark Grey <mark.asperia@gmail.com> wrote:

> Oh man, that did the charm something serious.  Very cool.
>
> Just for the the benefit of posterity, if you use this with twisted you
> need to make sure you call to reactor.run() passes kwarg
> installSignalHandlers=0, so the threading signals check out correctly.
>
>
> On Thu, Nov 29, 2012 at 1:28 PM, Ned Jackson Lovely <njl@njl.us> wrote:
>
>> On Thu, Nov 29, 2012 at 1:05 PM, Mark Grey <mark.asperia@gmail.com>
>> wrote:
>> > I am writing another service with twisted and was wondering where to
>> begin
>> > looking in the Werkzeug internals to possibly use a similar approach to
>> > reloading and restarting my Twisted server automatically while it is in
>> > development.  Any pointers or tips would be appreciated!
>>
>> https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L489
>>
>> --
>> njl
>>
>
>

Re: [flask] run_simple's reloader logic

From:
Mark Grey
Date:
2012-11-30 @ 17:36
I should've been clearer. I only intend to use the reloader for development
purposes anyway - it doens't make much sense in deployment.

I have a debug flag set in my configs for this purpose.

Thanks for noting it!

On Fri, Nov 30, 2012 at 1:56 AM, Yaniv Aknin <yaniv@aknin.name> wrote:

> If we're writing for posterity, I suggest noting you should use
> installSignalHandlers=0 only during development and only if you
> understand the consequences.
> Several twisted patterns I can think of benefit from well programmed
> 
reactor.stop()<http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorCore.html#stop>rather
than
> 
reactor.crash()<http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorCore.html#crash>-
without any signal handlers, you're effectively crashing the reactor on
> reception of many signals, including the common INT and TERM.
>
>  - Yaniv
>
>
> On Thu, Nov 29, 2012 at 9:34 PM, Mark Grey <mark.asperia@gmail.com> wrote:
>
>> Oh man, that did the charm something serious.  Very cool.
>>
>> Just for the the benefit of posterity, if you use this with twisted you
>> need to make sure you call to reactor.run() passes kwarg
>> installSignalHandlers=0, so the threading signals check out correctly.
>>
>>
>> On Thu, Nov 29, 2012 at 1:28 PM, Ned Jackson Lovely <njl@njl.us> wrote:
>>
>>> On Thu, Nov 29, 2012 at 1:05 PM, Mark Grey <mark.asperia@gmail.com>
>>> wrote:
>>> > I am writing another service with twisted and was wondering where to
>>> begin
>>> > looking in the Werkzeug internals to possibly use a similar approach to
>>> > reloading and restarting my Twisted server automatically while it is in
>>> > development.  Any pointers or tips would be appreciated!
>>>
>>>
>>> https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L489
>>>
>>> --
>>> njl
>>>
>>
>>
>

Re: [flask] run_simple's reloader logic

From:
Freedom Dumlao
Date:
2012-11-29 @ 18:22
You might consider looking at Watchdog: http://packages.python.org/watchdog/

It lets you monitor filesystem directories for changes. You could watch for
that and reload the server when a change was detected.


On Thu, Nov 29, 2012 at 1:05 PM, Mark Grey <mark.asperia@gmail.com> wrote:

> The flask/werkzeug reloader is pretty much the coolest thing that has ever
> happened to my web development.
>
> I am writing another service with twisted and was wondering where to begin
> looking in the Werkzeug internals to possibly use a similar approach to
> reloading and restarting my Twisted server automatically while it is in
> development.  Any pointers or tips would be appreciated!
>

Re: [flask] run_simple's reloader logic

From:
Jesse Dubay
Date:
2012-11-29 @ 18:27
Check out werkzeug.serving.run_with_reloader, which you can use as a
decorator:

https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L588

Jesse


On Thu, Nov 29, 2012 at 10:05 AM, Mark Grey <mark.asperia@gmail.com> wrote:

> The flask/werkzeug reloader is pretty much the coolest thing that has ever
> happened to my web development.
>
> I am writing another service with twisted and was wondering where to begin
> looking in the Werkzeug internals to possibly use a similar approach to
> reloading and restarting my Twisted server automatically while it is in
> development.  Any pointers or tips would be appreciated!
>