[Twisted-Python] twistd save state does not work
![](https://secure.gravatar.com/avatar/747d12aa1fe3aa5a83aae8e8a50f445b.jpg?s=120&d=mm&r=g)
Hello, I've readied my app for use with twistd, the daemonizing works, but a tap file is not saved upon exit (kill 'cat twisted.pid'). How can I enable the save state option? BTW I'm not using the -o option with twistd ;) Second ... is it possible to disable the twisted logging if you use twistd to start the app? Or is it possible to set a log level so that only warnings and errors are shown and my log is not flooded with (TCPServer) connection messages. - Remi -
![](https://secure.gravatar.com/avatar/747d12aa1fe3aa5a83aae8e8a50f445b.jpg?s=120&d=mm&r=g)
Remi Cool wrote:
The save state function only seems to work when you start with a tap in the firstplace. It then saves the state in appname-shutdown.tap ... ok but why doesn't it work when you start from a python file? My 2nd question about the logging still stands ... and is it possible to (re)set the name of the log file in the python file where application is defined? I have all paths for the app in an ini file (configParser) and it would not be a good solution to declare the logfile path somewhere else. - Remi -
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Fri, 29 Sep 2006 16:53:10 +0200, Remi Cool <mailinglists@smartology.nl> wrote:
It's implicitly disabled when loading an application from a Python file, since there is no guarantee that the application will be serializable. There is no way to explicitly re-enable it. I would suggest that this feature be added, but since most people seem to think tap files should be eliminated as soon as possible, pursuing this would probably involve a lot of debate that I'm not personally interested in participating in. I would suggest using an alternate mechanism for persistence.
My 2nd question about the logging still stands ...
It's not, although it certainly should be. I believe there is at least one ticket open in the tracker for improving the logging features of twistd.
The next release of Twisted will include a much more extensible way to interact with twistd which should satisfy this use-case. If you want to play with it in svn trunk@HEAD, you can take a look at the output of `twistd --help'. The command list which shows up at the end of that output can be extending using the plugin system, so you can add your command, which sets up logging or loads configuration from an ini, or whatever else you like. Jean-Paul
![](https://secure.gravatar.com/avatar/747d12aa1fe3aa5a83aae8e8a50f445b.jpg?s=120&d=mm&r=g)
Jean-Paul Calderone wrote:
It was an interesting feature but if tap is almost obsolete, I won't bother.
:)
Why not incorporate python logging into twisted? That way is easyer to incorporate modules without having to 'bother' with twisted. Or use modules which are not especially written for twisted. - Remi -
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Mon, 02 Oct 2006 08:23:47 +0200, Remi Cool <mailinglists@smartology.nl> wrote:
That wouldn't solve the problem, which is that twistd doesn't allow logging behavior to be customized. Once twistd allows customized logging behavior, you'll be able to customize it to use the stdlib logging module if you want. For quite a few reasons, I doubt we would change twisted.python.log to use the logging package directly. One of the biggest problems is that most of the modules which were not written particularly for Twisted are blocking, so using them would break any Twisted application. Jean-Paul
![](https://secure.gravatar.com/avatar/747d12aa1fe3aa5a83aae8e8a50f445b.jpg?s=120&d=mm&r=g)
Remi Cool wrote:
The save state function only seems to work when you start with a tap in the firstplace. It then saves the state in appname-shutdown.tap ... ok but why doesn't it work when you start from a python file? My 2nd question about the logging still stands ... and is it possible to (re)set the name of the log file in the python file where application is defined? I have all paths for the app in an ini file (configParser) and it would not be a good solution to declare the logfile path somewhere else. - Remi -
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Fri, 29 Sep 2006 16:53:10 +0200, Remi Cool <mailinglists@smartology.nl> wrote:
It's implicitly disabled when loading an application from a Python file, since there is no guarantee that the application will be serializable. There is no way to explicitly re-enable it. I would suggest that this feature be added, but since most people seem to think tap files should be eliminated as soon as possible, pursuing this would probably involve a lot of debate that I'm not personally interested in participating in. I would suggest using an alternate mechanism for persistence.
My 2nd question about the logging still stands ...
It's not, although it certainly should be. I believe there is at least one ticket open in the tracker for improving the logging features of twistd.
The next release of Twisted will include a much more extensible way to interact with twistd which should satisfy this use-case. If you want to play with it in svn trunk@HEAD, you can take a look at the output of `twistd --help'. The command list which shows up at the end of that output can be extending using the plugin system, so you can add your command, which sets up logging or loads configuration from an ini, or whatever else you like. Jean-Paul
![](https://secure.gravatar.com/avatar/747d12aa1fe3aa5a83aae8e8a50f445b.jpg?s=120&d=mm&r=g)
Jean-Paul Calderone wrote:
It was an interesting feature but if tap is almost obsolete, I won't bother.
:)
Why not incorporate python logging into twisted? That way is easyer to incorporate modules without having to 'bother' with twisted. Or use modules which are not especially written for twisted. - Remi -
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Mon, 02 Oct 2006 08:23:47 +0200, Remi Cool <mailinglists@smartology.nl> wrote:
That wouldn't solve the problem, which is that twistd doesn't allow logging behavior to be customized. Once twistd allows customized logging behavior, you'll be able to customize it to use the stdlib logging module if you want. For quite a few reasons, I doubt we would change twisted.python.log to use the logging package directly. One of the biggest problems is that most of the modules which were not written particularly for Twisted are blocking, so using them would break any Twisted application. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
Remi Cool