1

I am trying to execute gunicorn server in which I have to pass list of dict as input. But when I am sending empty string as value it's removed. My command is

import subprocess
cmd = """gunicorn 'myapp:create([{key: ""}])' --worker-class gevent -w 1 --bind 127.0.0.1:8019"""
subprocess.call([cmd], shell=True)

Inside myapp

#myapp.py
create(d_input):
    print(d_input)
    # OUT : [{key: }]

As you can see '' are eliminated so I am unable to parse list & dict. Is there any way to avoid this.

I have also tried passing input something like [{key : 'Something'}] in this case output is [{key : Something}] whereas I expect [{key : 'Something'}]. Any suggestion will be helpful

0

I encountered same issue converting list to json solved this for me.

import subprocess
cmd = """gunicorn 'myapp:create(json.dumps([{key: ""}]))' --worker-class gevent -w 1 --bind 127.0.0.1:8019"""
subprocess.call([cmd], shell=True)
0

Doesn't look like you need a shell for this. Try

cmd = ["gunicorn", 'myapp:create([{key: ""}])', "--worker-class", "gevent", "-w", "1", "--bind", "127.0.0.1:8019"]
subprocess.call(cmd, shell=False)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.