##// END OF EJS Templates
load kwarg traits before loading config...
load kwarg traits before loading config in `Configurable.__init__` avoids problems in the new init of traitlets that skips `_trait_default` if specified in kwargs, which means really nothing should be done before `HasTraits.__init__` has been called. This does mean that such values are assigned twice. Typically, this will have no effect, except when a value is set by both config and kwarg.

File last commit:

r7787:28b538a9
r20804:8d5ab280
Show More
daemonize.py
26 lines | 833 B | text/x-python | PythonLexer
"""daemonize function from twisted.scripts._twistd_unix."""
#-----------------------------------------------------------------------------
# Copyright (c) Twisted Matrix Laboratories.
# See Twisted's LICENSE for details.
# http://twistedmatrix.com/
#-----------------------------------------------------------------------------
import os, errno
def daemonize():
# See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
if os.fork(): # launch child and...
os._exit(0) # kill off parent
os.setsid()
if os.fork(): # launch child and...
os._exit(0) # kill off parent again.
null = os.open('/dev/null', os.O_RDWR)
for i in range(3):
try:
os.dup2(null, i)
except OSError as e:
if e.errno != errno.EBADF:
raise
os.close(null)