[Twisted-Python] Use of 'twistd' utility with command-line arguments
I came across some problem using 'twistd' utility - that I would not
have expected from it. The problem is - using 'twistd' to start
application that requires command-line arguments. In other words, I
would expect that 'twistd' passes command-line arguments to Python
application - just as Python does.
But... I get following error:
Usage: twistd [options]
Options:
--savestats save the Stats object rather than the text
output of
the profiler.
-o, --no_save do not save state on shutdown
-e, --encrypted The specified tap/aos/xml file is encrypted.
.........................
.........................
/usr/bin/twistd: option -a not recognized
when application is started either as 'twistd -y
python
[argList] twistd -y [argList]
Second question to Twisted development team: how such an important case has slipped attention? I suggest this to be added to bug fix requests, with high priority. Kind regards, Valeriy Pogrebitskiy vpogrebi@verizon.net
On Thu, Oct 1, 2009 at 2:17 PM, Valeriy Pogrebitskiy
I came across some problem using 'twistd' utility - that I would not have expected from it. The problem is - using 'twistd' to start application that requires command-line arguments. In other words, I would expect that 'twistd' passes command-line arguments to Python application - just as Python does.
While this is a reasonable expectation, twistd does quite a lot and it wouldn't be quite right to pass on all the arguments in a flat list the way Python does.
My question is: how is it possible to use 'twistd' to start applications that do require command-line arguments? Does anyone have suggestions?
twistd doesn't do this for scripts passed with the '-y' option. Those are supposed to be fully-formed configuration files; the options are present in the file itself. However, it's fairly straightforward to get what you want. Instead of writing a python configuration file, write a plug-in for twistd. The technique for doing so is documented here: http://twistedmatrix.com/projects/core/documentation/howto/tap.html Hope this helps.
I came across some problem using 'twistd' utility - that I would not have expected from it. The problem is - using 'twistd' to start application that requires command-line arguments. In other words, I would expect that 'twistd' passes command-line arguments to Python application - just as Python does.
But... I get following error:
... You can do this with twistd plugins: http://twistedmatrix.com/projects/core/documentation/howto/tap.html
Thank you! I still disagree with the following statement:
While this is a reasonable expectation, twistd does quite a lot and it wouldn't be quite right to pass on all the arguments in a flat list the way Python does.
Something can be done about that. One possible approach could be to
use two argument lists (one - 'twistd' arguments, second -
application's arguments) and enforce following rule(s):
- all arguments that follow after 'twistd' but before Python file name
(*.py) are considered as 'twistd' arguments (loaded into <twistdArgs>
list;
- all arguments that follow Python file name (*.py) are considered as
Python application's arguments (loaded into <appArgs> list and get
passed to that application)
Thus, it should be possible to execute following commands:
twistd
On Thu, Oct 1, 2009 at 2:17 PM, Valeriy Pogrebitskiy
wrote: I came across some problem using 'twistd' utility - that I would not have expected from it. The problem is - using 'twistd' to start application that requires command-line arguments. In other words, I would expect that 'twistd' passes command-line arguments to Python application - just as Python does.
While this is a reasonable expectation, twistd does quite a lot and it wouldn't be quite right to pass on all the arguments in a flat list the way Python does.
My question is: how is it possible to use 'twistd' to start applications that do require command-line arguments? Does anyone have suggestions?
twistd doesn't do this for scripts passed with the '-y' option. Those are supposed to be fully-formed configuration files; the options are present in the file itself.
However, it's fairly straightforward to get what you want. Instead of writing a python configuration file, write a plug-in for twistd. The technique for doing so is documented here:
http://twistedmatrix.com/projects/core/documentation/howto/tap.html
Hope this helps. _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Oct 2, 2009, at 12:14 PM, Valeriy Pogrebitskiy wrote:
I suggest that Twisted dev. team looks into implementing this...
Since we're telling other people how to spend their time...I suggest that you supply a patch. Thanks, S
On 04:14 pm, vpogrebi@verizon.net wrote:
Thank you!
I still disagree with the following statement:
While this is a reasonable expectation, twistd does quite a lot and it wouldn't be quite right to pass on all the arguments in a flat list the way Python does.
Something can be done about that. One possible approach could be to use two argument lists (one - 'twistd' arguments, second - application's arguments) and enforce following rule(s):
Given this:
However, it's fairly straightforward to get what you want. Instead of writing a python configuration file, write a plug-in for twistd. The technique for doing so is documented here:
what is your motivation for seeking out this feature? Also, Glyph didn't mention #1490, an open ticket describing yet another way twistd might be invoked which allows command line arguments to be passed to the application. Jean-Paul
On Fri, Oct 2, 2009 at 12:14 PM, Valeriy Pogrebitskiy
Something can be done about that. One possible approach could be to use two argument lists (one - 'twistd' arguments, second - application's arguments) and enforce following rule(s):
As Jean-Paul mentioned, there is a ticket which almost exactly describes your idea: #1490. In particular, you can read my last comment explaining what that ticket is supposed to be about: http://twistedmatrix.com/trac/ticket/1490#comment:39 If you'd like to implement what's specified there, we would be happy to receive your patch :). Making 'twistd foo.py' equivalent to 'twistd run foo' is a trivial afterthought once #1490 is implemented.
participants (5)
-
exarkun@twistedmatrix.com
-
Glyph Lefkowitz
-
Itamar Turner-Trauring
-
Steve Steiner (listsin)
-
Valeriy Pogrebitskiy