List Info

Thread: Threading / Signal problem with cherrypy 3.0.1 / mod_python under Win32?




Threading / Signal problem with cherrypy 3.0.1 / mod_python under Win32?
country flaguser name
United States
2007-05-01 08:56:18
Hope I've done the right research on this one. Essentials:

WinXP SP2
Python 2.4.4
Latest stable release of CherryPy (v3.0.1). test.py runs ok
(except
for "No handlers could be found for logger
"cherrypy.error"").
Fresh installation of Apache 2.2.4
Mod_python 3.3.1. mod_python.testhandler works fine
(including with
mod_auth_sspi which is the point of all this!)

My existing application, running for several months now on
the
cherrypy standalone server, runs fine. I wanted to
authenticate users
via sspi and reckoned that mod_python / mod_sspi was the
simplest way
to do this. As mentioned above, the combination is ok for
the
mod_python test case.

I pulled the sample app & http.conf out of the docstring
for
_cpmodpy.py and consistently got a "Unrecoverable error
in the
server." with nothing in the Apache error.log. Took me
longer than it
should have done to realise that this was a cherrypy error,
not a
mod_python one (might be worth a cherrypy prefix on that
barebones
error message; happy to provide a path). And longer again to
think of
turning cherrypy logging on to an external filename. When I
did, I got
the traceback below:

<traceback>
[01/May/2007:14:34:37]  Traceback (most recent call last):
  File
"c:python24Libsite-packagescherrypy_cpmodpy.py&quo
t;, line 116,
in handler
    setup(req)
  File
"c:python24Libsite-packagescherrypy_cpmodpy.py&quo
t;, line 79,
in setup
    func()
  File "c:work_in_progressheatdevmyapp.py",
line 19, in
setup_server
    cherrypy.engine.start(blocking=True)
  File
"c:python24Libsite-packagescherrypy_cpengine.py&qu
ot;, line 84,
in start
    self._set_signals()
  File
"c:python24Libsite-packagescherrypy_cpengine.py&qu
ot;, line
298, in _set_signals
    signal.signal(signal.SIGTERM, self.SIGTERM)
ValueError: signal only works in main thread

</traceback>

For completeness, this is the mini-app I'm using, although
it's cut-
and-pasted from _cpmodpy.py with only the error log added:

<myapp.py>
import cherrypy

class Root:
    cherrypy.expose
    def index(self):
        return 'Hi there, Ho there, Hey there'


# We will use this method from the mod_python configuration
# as the entyr point to our application
def setup_server():
    cherrypy.tree.mount(Root())
    cherrypy.config.update({'log.error_file' : 'c:/temp/
cherrypy.log',
                            'environment': 'production',
                            'log.screen': False,
                            'show_tracebacks': False})
    # You must start the engine in a non-blocking fashion
    # so that mod_python can proceed
    cherrypy.engine.start(blocking=False)

</myapp.py>

I'm a little stuck. It's possible something's changed in
the
mod_python setup since that example was written, but I
wouldn't know
where to look. Likewise on the cherrypy side. Any hints?

Thanks
TJG


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Threading / Signal problem with cherrypy 3.0.1 / mod_python under Win32?
country flaguser name
United States
2007-05-01 09:37:50
Tim Golden wrote:
> Hope I've done the right research on this one.
Essentials:
> 
> WinXP SP2
> Python 2.4.4
> Latest stable release of CherryPy (v3.0.1). test.py
runs ok (except
> for "No handlers could be found for logger
"cherrypy.error"").
> Fresh installation of Apache 2.2.4
> Mod_python 3.3.1. mod_python.testhandler works fine
(including with
> mod_auth_sspi which is the point of all this!)

[... snip problems culminating in ...]

> <traceback>
...
>   File
"c:python24Libsite-packagescherrypy_cpengine.py&qu
ot;, line
> 298, in _set_signals
>     signal.signal(signal.SIGTERM, self.SIGTERM)
> ValueError: signal only works in main thread
> 
> </traceback>

Well a bit more looking around (not that I hadn't tried
already) led me to Graham D's recent mod_wsgi and its
mailing list where he points to the fact that cherrypy
is setting signal handlers which might interfere with
things:

http://code.google.com/p/modwsgi/wiki/IntegrationWi
thCherryPy

A perusal of the _cpengine module docstrings suggested that
setting the SIGHUP/SIGTERM class attributes to None would
turn off signal handling seems to have done the trick (at
least so far as this). I added:

cherrypy._cpengine.Engine.SIGHUP = None
cherrypy._cpengine.Engine.SIGTERM = None
cherrypy._cpengine.Engine.autoreload_on = False

to the top of my code and it gets past the error... and
on to a more sedate cherrypy error (404 - "The path
/app
was not found") which I'm better placed to handle.

If there are other/better solutions that what I've
proposed here, please feel free to educate me!

TJG

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Threading / Signal problem with cherrypy 3.0.1 / mod_python under Win32?
user name
2007-05-01 09:59:06
On 5/1/07, Tim Golden <tjgoldengmail.com> wrote:
> A perusal of the _cpengine module docstrings suggested
that
> setting the SIGHUP/SIGTERM class attributes to None
would
> turn off signal handling seems to have done the trick
(at
> least so far as this). I added:
>
> cherrypy._cpengine.Engine.SIGHUP = None
> cherrypy._cpengine.Engine.SIGTERM = None
> cherrypy._cpengine.Engine.autoreload_on = False
>
> to the top of my code and it gets past the error...
and
> on to a more sedate cherrypy error (404 - "The
path /app
> was not found") which I'm better placed to
handle.
>
> If there are other/better solutions that what I've
> proposed here, please feel free to educate me!

That sounds like the right way to handle it.  One thing
though: you
can simply reference cherrypy.engine rather than
cherrypy._cpengine.Engine.

Another approach you might try (if it works in conjunction
with
mod_auth_sspi) is using mod_proxy.  I have been using that
setup for
about a year and a half now hosting my projects site
(http://projects.dowski.com
) as well as a few more CP sites.  You can
find more info about this method here:
http://tools
.cherrypy.org/wiki/ModProxy.

Christian
http://www.dowski.com

ps
Back when I was sysadmin for a largely Windows-based
datacenter I
found your WMI tools very useful!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Threading / Signal problem with cherrypy 3.0.1 / mod_python under Win32?
country flaguser name
United States
2007-05-01 10:15:41
[Apols. if resend; forgot to use my GMail addr]

Christian Wyglendowski wrote:
> On 5/1/07, Tim Golden <tjgoldengmail.com> wrote:
>> A perusal of the _cpengine module docstrings
suggested that
>> setting the SIGHUP/SIGTERM class attributes to None
would
>> turn off signal handling seems to have done the
trick (at
>> least so far as this). I added:
>>
>> cherrypy._cpengine.Engine.SIGHUP = None
>> cherrypy._cpengine.Engine.SIGTERM = None
>> cherrypy._cpengine.Engine.autoreload_on = False
>>
>> to the top of my code and it gets past the error...
and
>> on to a more sedate cherrypy error (404 - "The
path /app
>> was not found") which I'm better placed to
handle.
>>
>> If there are other/better solutions that what I've
>> proposed here, please feel free to educate me!
> 
> That sounds like the right way to handle it.  One thing
though: you
> can simply reference cherrypy.engine rather than
> cherrypy._cpengine.Engine.

Wasn't sure about that; thanks for clarifying. I'm a little
confused; am I the first person to experience this? Is
there
something unusual in my setup that doesn't occur elsewhere?
(Win32 perhaps?). I'm happy to provide a doc patch, but
best
not if it's some localised condition no-one else will meet.

> Another approach you might try (if it works in
conjunction with
> mod_auth_sspi) is using mod_proxy.  I have been using
that setup for
> about a year and a half now hosting my projects site
> (http://projects.dowski.com
) as well as a few more CP sites.  You can
> find more info about this method here:
> http://tools
.cherrypy.org/wiki/ModProxy.

Thanks for the heads-up. I did toy with mod_proxy but I
thought I ought to be able to get mod_python to work in any
case. (And I've got a feeling it won't work with SSPI).
I'll
go back to it and have a look.

> Christian
> http://www.dowski.com
> 
> ps
> Back when I was sysadmin for a largely Windows-based
datacenter I
> found your WMI tools very useful!

Hey! Thanks for that. I don't feel so bad about soaking
up your cherrypy expertise now 

TJG


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )