On Tue, May 13, 2008 at 11:59 PM, slummer <[EMAIL PROTECTED]> wrote:
>
> On linux, I found webpy cann't run as a daemon. I write a function
> daemon:
>
> def daemonize():
> """Become a Linux/UNIX daemon"""
> import os,sys
> os.chdir('/')
> if os.fork():
> os._exit(0)
>
> os.setsid()
> sys.stdin = sys.__stdin__ = open('/dev/null','r')
> sys.stdout = sys.__stdout__ = open('/dev/null','w')
> sys.stdout = sys.__stderr__ = os.dup(sys.stdout.fileno())
>
> if __name__ == "__main__":
> import sys
> strPlatform = sys.platform
> if strPlatform != 'win32':
> daemonize()
>
> and the run it on linux, but it give the follow error:
>
> Traceback (most recent call last):
> File "VSIMSWebServer.py", line 894, in <module>
> File "/usr/lib/python2.5/site-packages/web/request.py", line 153, in
> run
> File "/usr/lib/python2.5/site-packages/web/wsgi.py", line 54, in
> runwsgi
> File "/usr/lib/python2.5/site-packages/web/httpserver.py", line 220,
> in runsimple
> AttributeError: 'int' object has no attribute 'write'
>
> how can i do?
> thanks for all
>
Hi,
doing a simple google-search i've found this:
class NullDevice:
def write(self, s):
pass
sys.stdin.close()
sys.stdout = NullDevice()
sys.stderr = NullDevice()
taken from here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
hope its useful to you
Regards,
Mauro
--
JID: [EMAIL PROTECTED]
----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCM/O d->dpu$ s-:- a-->a+++$ C+++
LU P+ L++ E W+++ N !o K w O !M !V
PS+ PE Y+ PGP t 5- X R tv++ b- DI D++ G+ e
h!>h-- r>r+++ y+
----END GEEK CODE BLOCK----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---