Quantcast

Patch to support Autoreloading under Jython 2.5.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Patch to support Autoreloading under Jython 2.5.0

Jeremy Ouellette

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch to support Autoreloading under Jython 2.5.0

Robert Brewer-4

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
[hidden email]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Patch to support Autoreloading under Jython 2.5.0

Jeremy Ouellette

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).

On Sep 1, 11:04 pm, "Robert Brewer" <[hidden email]> wrote:

> 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/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
> [hidden email]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Loading...