I'm just getting started on threading and was wondering why the
following code does not work (i know globals is bad style - I'll
eliminate them eventually). All I get is a blank cursor flashing.
Many thanks
Jon
import threading
import sys
import time
global g_datum
global g_rawfile
global g_rawtext
global g_overs
global g_currentover
global g_secondspertic k
g_secondspertic k=5
g_datum=time.ti me()
g_currenttick=1
g_rawfile=open( 'inputashes.txt ','r')
g_rawtext=g_raw file.read()
g_overs=g_rawte xt.split('<P>')
g_currentover=0
class ImapThread(thre ading.Thread):
def run(self):
global g_currenttick
if time.time() (g_datum + (g_secondsperti ck *
g_currenttick)) :
print "Ticked %s" % g_currenttick
g_currenttick=g _currenttick+1
print g_currenttick
sys.stdout.flus h()
time.sleep(0.01 )
def main():
ImapThread().st art()
while 1:
pass
if __name__ == "__main__":
main()
following code does not work (i know globals is bad style - I'll
eliminate them eventually). All I get is a blank cursor flashing.
Many thanks
Jon
import threading
import sys
import time
global g_datum
global g_rawfile
global g_rawtext
global g_overs
global g_currentover
global g_secondspertic k
g_secondspertic k=5
g_datum=time.ti me()
g_currenttick=1
g_rawfile=open( 'inputashes.txt ','r')
g_rawtext=g_raw file.read()
g_overs=g_rawte xt.split('<P>')
g_currentover=0
class ImapThread(thre ading.Thread):
def run(self):
global g_currenttick
if time.time() (g_datum + (g_secondsperti ck *
g_currenttick)) :
print "Ticked %s" % g_currenttick
g_currenttick=g _currenttick+1
print g_currenttick
sys.stdout.flus h()
time.sleep(0.01 )
def main():
ImapThread().st art()
while 1:
pass
if __name__ == "__main__":
main()
Comment