##// END OF EJS Templates
Merging -r 1177 from lp:ipython with fixes and resolutions....
Merging -r 1177 from lp:ipython with fixes and resolutions. The main conflicts I had to fix were in ultratb. I have removed the ultraTB.py in IPython/kernel/core. Now IPython/core/ultratb.py is being used everywhere. Also I have protected the calls to ipapi.get to see if None is returned. This happens when trial IPython.kernel is run.

File last commit:

r1338:72652d65
r2124:4a54d9d3 merge
Show More
pwordfreq_skel.py
35 lines | 982 B | text/x-python | PythonLexer
#!/usr/bin/env python
"""Parallel word frequency counter."""
from itertools import repeat
from wordfreq import print_wordfreq, wordfreq
def pwordfreq(rc, text):
"""Parallel word frequency counter.
rc - An IPython RemoteController
text - The name of a string on the engines to do the freq count on.
"""
if __name__ == '__main__':
# Create a MultiEngineClient
from IPython.kernel import client
ipc = client.MultiEngineClient()
# Run the wordfreq script on the engines.
ipc.run('wordfreq.py')
# Run the serial version
print "Serial word frequency count:"
text = open('davinci.txt').read()
freqs = wordfreq(text)
print_wordfreq(freqs, 10)
# The parallel version
print "\nParallel word frequency count:"
files = ['davinci%i.txt' % i for i in range(4)]
ipc.scatter('textfile', files)
ipc.execute('text = open(textfile[0]).read()')
pfreqs = pwordfreq(ipc,'text')
print_wordfreq(freqs)