I am trying to connect to MongoDB using Anaconda3 (64-bit). The code I am using:
import signal
import subprocess
proc = subprocess.Popen(['mongod'] preexec_fn=os.setsid)
But I am getting below error
AttributeError Traceback (most recent call last) <ipython-input-45-f94c14f3a553> in <module>() 2 import subprocess 3 #proc = subprocess.Popen('mongod', close_fds=True) ----> 4 proc =subprocess.Popen(['mongod'], shell=True, preexec_fn=os.setsid) AttributeError: module 'os' has no attribute 'setsid'
On Windows, you cannot use os.setsid
, preexec_fn
parameter subprocess.Popen
also unavailable.
You can create a subprocess with a new process group with creationflags` parameter documentation:
proc = subprocess.Popen(
['mongod'],
shell=True,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With