Skip to content

Instantly share code, notes, and snippets.

@ntamas
Created June 30, 2010 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntamas/459154 to your computer and use it in GitHub Desktop.
Save ntamas/459154 to your computer and use it in GitHub Desktop.
"""
``vuvuzela.py`` adds the glorious sound of the vuvuzela to any
Python program.
Based on the excellent idea of Chris Williams. See also:
<http://search.cpan.org/~bingos/Acme-Vuvuzela-0.02>
Usage::
>>> import vuvuzela
"""
import os, random, sys, time
__author__ = "Tamas Nepusz"
__license__ = "MIT"
class Vuvuzela(object):
def __init__(self):
self.PID = None
def start(self):
if self.PID:
return
self.PID = os.fork()
if not self.PID:
sys.stdout.write("B")
sys.stdout.flush()
while True:
sys.stdout.write(random.choice("Zzzz"))
sys.stdout.flush()
time.sleep(0.2)
def stop(self):
if self.PID:
os.kill(self.PID)
self.PID = None
Vuvuzela().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment