Django commands interacting
I have the following situation: I have one django command that is
listening to an outside source for information. I don't know how long said
stream is, what the format or what the terminating sequence is. So I was
thinking that I would listen indefinitely using one command and have
another command stop the listening at some point. The issue is that since
the two commands are running in separate python shells, I can't seem to
set a global variable to share between the two. Something like:
globalvar = True
class Command(NoArgsCommand):
def handle_noargs(self, **options):
global globalvar
while globalvar:
print "Is True"
time.sleep(1)
and
class Command(NoArgsCommand):
def handle_noargs(self, **options):
global globalvar
globalvar = False
The variable globalvar doesn't exist in the context of the second command.
Is there any way other than storing the information in the database that I
can somehow stop/alter the way the first command is running?
No comments:
Post a Comment