Q:

Reload self-made module

Files:

File 1: metrobot.py
File 2: irc.py
File 3: cmd.py

MetroBot.py starts irc.py, irc.py makes a while loop which then uses cmd.py.
I try reloading the cmd module from irc.py. After i've reloaded it, the changes in cmd.py still won't take effect.
Reload code snippet:
if ":!reload" in self.buf:
  reload(sys.modules['cmd'])

I've also tried 
reload(cmd)

None of the two works.
Anyone know what cause the reload to not work, or another simple way? This script is meant to be running at all times. 

A:

I created the following three mini-scripts to test this and it works:
bot.py:
import irc

def start():
  irc.run()

irc.py:
import cmd, time

def run():
  while 1:
    print cmd.dothis()
    reload(cmd)
    time.sleep(1)

cmd.py:
def dothis():
  return 1

Now if you run bot.start() it will print "1" once a second and if I then edit cmd.py at some point to say return 2 it prints "2".. Obviously I'm imagining this is a whole way simpler than whatever code you're having, but you'll need to post some samples to help us answer you better. Or try breaking your code down and testing the reload with a stripped down version of your code.

