Patch to support Autoreloading under Jython 2.5.0

3 views
Skip to first unread message

Jeremy Ouellette

unread,
Sep 1, 2009, 9:02:28 PM9/1/09
to cherrypy-devel
Hello-

I recently started working with CherryPy 3.1.2 under Jython 2.5.0, and
everything seems to work very nicely so far with the exception of one
minor threading patch I found in a blog post and autoreloading.

To get autoreloading working, it seems raising a SystemRestart
exception is the correct mechanism on Jython (there's similar code in
the Django autoreload utility). I updated the _do_execv method in
wspbus.py as follows:

def _do_execv(self):
"""Re-execute the current process.

This must be called from the main thread, because certain
platforms
(OS X) don't allow execv to be called in a child thread very
well.
"""

if sys.platform[:4] == 'java':
from _systemrestart import SystemRestart
raise SystemRestart
else:
args = sys.argv[:]
self.log('Re-spawning %s' % ' '.join(args))
args.insert(0, sys.executable)
if sys.platform == 'win32':
args = ['"%s"' % arg for arg in args]
os.execv(sys.executable, args)

What's the appropriate mechanism to contribute patches to the
project? I suspect I'll be working through more minor issues as I
continue working with CherryPy on Jython.

Thanks,
Jeremy

Robert Brewer

unread,
Sep 1, 2009, 11:04:01 PM9/1/09
to cherryp...@googlegroups.com
Jeremy Ouellette wrote:
> I recently started working with CherryPy 3.1.2 under Jython 2.5.0, and
> everything seems to work very nicely so far with the exception of one
> minor threading patch I found in a blog post and autoreloading.
>
> To get autoreloading working, it seems raising a SystemRestart
> exception is the correct mechanism on Jython (there's similar code in
> the Django autoreload utility). I updated the _do_execv method in
> wspbus.py as follows:
>
> def _do_execv(self):
> """Re-execute the current process.
>
> This must be called from the main thread, because certain
> platforms
> (OS X) don't allow execv to be called in a child thread very
> well.
> """
>
> if sys.platform[:4] == 'java':
> from _systemrestart import SystemRestart
> raise SystemRestart
> else:
> args = sys.argv[:]
> self.log('Re-spawning %s' % ' '.join(args))
> args.insert(0, sys.executable)
> if sys.platform == 'win32':
> args = ['"%s"' % arg for arg in args]
> os.execv(sys.executable, args)

Thanks!!

> What's the appropriate mechanism to contribute patches to the
> project? I suspect I'll be working through more minor issues as I
> continue working with CherryPy on Jython.

http://www.cherrypy.org/newticket is best. There's a guest name/pw on
every page. If you end up doing a sizable chunk of work, join #cherrypy
on irc.oftc.net and we'll get you set up with a dev account.


Robert Brewer
fuma...@aminus.org

Jeremy Ouellette

unread,
Sep 1, 2009, 11:23:23 PM9/1/09
to cherrypy-devel
Excellent- just submitted it (apologies for the poorly formatted
defect text, pasted in the code and clicked submit before I realized
there was an "attach" option).
> http://www.cherrypy.org/newticketis best. There's a guest name/pw on
> every page. If you end up doing a sizable chunk of work, join #cherrypy
> on irc.oftc.net and we'll get you set up with a dev account.
>
> Robert Brewer
> fuman...@aminus.org
Reply all
Reply to author
Forward
0 new messages