Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install turkmenbashi

How to install Turkmenbashi

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install turkmenbashi
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
2.0 Available View build log
1.1.0 Available View build log
1.0.0.01 Available View build log
1.0 Available View build log
Windows (64-bit)
2.0 Available View build log
1.1.0 Available View build log
1.0.0.01 Available View build log
1.0 Available View build log
Mac OS X (10.5+)
2.0 Available View build log
1.1.0 Available View build log
1.0.0.01 Available View build log
1.0 Available View build log
Linux (32-bit)
2.0 Available View build log
1.1.0 Available View build log
1.0.0.01 Available View build log
1.0 Available View build log
Linux (64-bit)
2.0 Available View build log
1.1.0 Available View build log
1.0.0.01 Available View build log
1.0 Available View build log
 
License
MIT
Imports
Lastest release
version 2.0 on May 23rd, 2012

The Turkmenbashi Daemon Creator is a helpful resource to write an UNIX daemon in Python, by providing functions to start, stop and restart and defined functions to control every aspect on daemon execution.

Why the name

This piece of code is part of a proprietary project. One night, after a long conversation about modern history with some friends, I tried to explain how it works in the same “historical” terms, just making fun about it.

This class is like a “dictator” who does a “coup d’etat”, “daemonizes” other citizens (who are the processes under his control) and throws them away from “their city” (the process collection) closing access to basic resources (“file descriptors”), and the “daemonized citizens” are known to be alive because there is no defunction and they still can write logs about their lives.

Basically, in that conversation I found out that the Turkmenbashi lived like a rock star during his dictatorship. He even made a golden image of himself that is always looking at the sun!. Despite the fact that he was a dictator, his sense of humour deserves to be recognized.

How it works

According to PEP 3143, a UNIX daemon process should close all open file descriptors, change the current working directory to something helpful, reset the file access creation mask to something more appropriate, detach from process group and control terminal and stop receiving I/O signals. However, it does not create childrens when getting SIGCLD signals and it does not provide System V init startup management.

How to implement it

What this class does is to provide a collection of methods that are needed to convert a class into a daemon. This class must extend the Turkmenbashi class (correctly kept in the Python Library Path) and use some methods to configure the instance.

This is an implementation of a daemon that does nothing but print debugs:

import turkmenbashi

class DebugDaemon (turkmenbashi.daemon_creator):

    def config(self):
        """
        This function can be called setup, config or whatever you
        want, just call it before turk_start()
        """
        self.turk_state['debugger'] = True
        self.turk_state['pid_file'] = "/var/run/daemon.pid"
        self.turk_state['temp_dir'] = "/tmp"
        self.turk_state['timewait'] = 60
        self.turk_state['logclass'] = somelogger

    def daemon(self):
        print "A debug message"

if __name__=="__main__":
    d = DebugDaemon()
    d.config()
    d.turk_start(d.daemon)

How to run it

I created a small piece of code to start, stop and restart a daemon. You should modify it to suit your needs:

import os
import sys

import turkmenbashi

daemon = turkmenbashi.daemoncreator()
daemon = turkmenbashi.daemoncreator()
daemon.turk_start(function)   # starts the daemon.
daemon.turk_restart()         # stops and then starts the daemon.
daemon.turk_stop()            # stops the daemon.

Notice that if you use turk_restart(), the daemon does not get unloaded from memory. If you made changes to your source code, these won't load, until you do a full stop/start cycle.

Source

The source can be browsed at [http://github.com/rfc83/Turkmenbashi](http://github.com/rfc83/Turkmenbashi "Turkmenbashi Daemon Creator")

Contact me

For any requests, please contact me at: <rfuentealbac.83@gmail.com>

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:7

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.