##// END OF EJS Templates
Added .pid files to ipcluster and ipcontroller and daemon mode....
Added .pid files to ipcluster and ipcontroller and daemon mode. * The ClusterDir object now creates a /pid sub-dir for storing .pid files. * Both ipcluster and ipcontroller now create .pid files upon starting. * Both ipcluster and ipcontroller check for the existance of .pid files before starting and won't start if another instance is running. * ipcluster has a daemon mode (--daemon/--nodaemon) will daemonize the process and then write the .pid file. * Added a "ipcluster stop" subcommand which looks for a .pid file and kills the process.

File last commit:

r1337:53a3e331
r2313:d3d8ba63
Show More
wordfreq.py
22 lines | 638 B | text/x-python | PythonLexer
"""Count the frequencies of words in a string"""
def wordfreq(text):
"""Return a dictionary of words and word counts in a string."""
freqs = {}
for word in text.split():
freqs[word] = freqs.get(word, 0) + 1
return freqs
def print_wordfreq(freqs, n=10):
"""Print the n most common words and counts in the freqs dict."""
words, counts = freqs.keys(), freqs.values()
items = zip(counts, words)
items.sort(reverse=True)
for (count, word) in items[:n]:
print word, count
if __name__ == '__main__':
import gzip
text = gzip.open('HISTORY.gz').read()
freqs = wordfreq(text)