Ghopper21
Ghopper21

Reputation: 10477

When launching a Twisted application via twistd, how to send command line arguments to the application?

When launching a Twisted application like this,

twistd -y application.py

how can you send application specific command line arguments, e.g.

twistd -y application.py app_arg1 app_arg2 --app_flag

or someting similar?

What happens with the syntax above is that twistd will try to interpret all the arguments for itself (i.e. arguments to twistd) and thus (typically) fail with a bad-command-line-argument message.

Upvotes: 0

Views: 1050

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48325

You cannot pass arguments to a tac file (application.py is a tac file, even though its name does not reflect this, since you are using it with the -y option).

A tac file is configuration. It doesn't take configuration.

If you want to be able to pass command line configuration information to your application, you probably want to write a twistd plugin instead of a tac file.

See the plugin howto.

Upvotes: 2

Related Questions