##// END OF EJS Templates
Merge pull request #8234 from minrk/parallel-daemonize...
Thomas Kluyver -
r21099:5209ec5d merge
parent child Browse files
Show More
@@ -0,0 +1,26 b''
1 """daemonize function from twisted.scripts._twistd_unix."""
2
3 #-----------------------------------------------------------------------------
4 # Copyright (c) Twisted Matrix Laboratories.
5 # See Twisted's LICENSE for details.
6 # http://twistedmatrix.com/
7 #-----------------------------------------------------------------------------
8
9 import os, errno
10
11 def daemonize():
12 # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
13 if os.fork(): # launch child and...
14 os._exit(0) # kill off parent
15 os.setsid()
16 if os.fork(): # launch child and...
17 os._exit(0) # kill off parent again.
18 null = os.open('/dev/null', os.O_RDWR)
19 for i in range(3):
20 try:
21 os.dup2(null, i)
22 except OSError as e:
23 if e.errno != errno.EBADF:
24 raise
25 os.close(null)
26
@@ -1,26 +1,4 b''
1 """daemonize function from twisted.scripts._twistd_unix."""
1 from warnings import warn
2
3 #-----------------------------------------------------------------------------
4 # Copyright (c) Twisted Matrix Laboratories.
5 # See Twisted's LICENSE for details.
6 # http://twistedmatrix.com/
7 #-----------------------------------------------------------------------------
8
9 import os, errno
10
11 def daemonize():
12 # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
13 if os.fork(): # launch child and...
14 os._exit(0) # kill off parent
15 os.setsid()
16 if os.fork(): # launch child and...
17 os._exit(0) # kill off parent again.
18 null = os.open('/dev/null', os.O_RDWR)
19 for i in range(3):
20 try:
21 os.dup2(null, i)
22 except OSError as e:
23 if e.errno != errno.EBADF:
24 raise
25 os.close(null)
26
2
3 warn("IPython.utils.daemonize has moved to ipython_parallel.apps.daemonize")
4 from ipython_parallel.apps.daemonize import daemonize
@@ -16,18 +16,18 b' from IPython.config.application import catch_config_error'
16 from IPython.config.loader import Config
16 from IPython.config.loader import Config
17 from IPython.core.application import BaseIPythonApplication
17 from IPython.core.application import BaseIPythonApplication
18 from IPython.core.profiledir import ProfileDir
18 from IPython.core.profiledir import ProfileDir
19 from IPython.utils.daemonize import daemonize
20 from IPython.utils.importstring import import_item
19 from IPython.utils.importstring import import_item
21 from IPython.utils.py3compat import string_types
20 from IPython.utils.py3compat import string_types
22 from IPython.utils.sysinfo import num_cpus
21 from IPython.utils.sysinfo import num_cpus
23 from IPython.utils.traitlets import (Integer, Unicode, Bool, CFloat, Dict, List, Any,
22 from IPython.utils.traitlets import (Integer, Unicode, Bool, CFloat, Dict, List, Any,
24 DottedObjectName)
23 DottedObjectName)
25
24
26 from ipython_parallel.apps.baseapp import (
25 from .baseapp import (
27 BaseParallelApplication,
26 BaseParallelApplication,
28 PIDFileError,
27 PIDFileError,
29 base_flags, base_aliases
28 base_flags, base_aliases
30 )
29 )
30 from .daemonize import daemonize
31
31
32
32
33 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now