New development tools for Python Folks
Tom Hazel
thazel at equipecom.com
Wed Jan 10 11:01:12 EST 2001
Python Folks,
I have been a long user & lover of python since 1992. Over the years I have
created a tool kit for C++ software development. I have also created some
useful python interfaces to these tools (Timers, IO processing, Threads,
Events, Locks, TCP Socket Server etc...). The end of this email has three
python test programs demonstrating some of the python interfaces.
take a look at http://txobject.sourceforge.net/
see REAMDEs in tar balls to build txObject ATK 1.3 and the txPyObject ATK
1.3
Enjoy
Tom
##########################################################################
# Threads
##########################################################################
import txLock # locks are not used in this test, but feel free to use them
import txEvent
import txThread
EXIT_FLAG = 0
EXIT_EVENT = txEvent.txEvent("EXIT")
def func(*args):
print 'args from func call : ', args
while not EXIT_FLAG:
print 'looping'
txThread.yield(EXIT_EVENT, 1000)
print 'Starting thread test'
txThread.start(func, ("abc", 123))
txThread.yield(10000) # wait ten seconds
EXIT_FLAG = 1
txEvent.trigger(EXIT_EVENT)
##########################################################################
# Timers
##########################################################################
import txTimer
import txEvent
import txThread
import txExtendedTimer # this is not used here, but feel free to use it
COUNT = 0
EXIT_EVENT = txEvent.txEvent("EXIT")
def callback (*args):
global COUNT
print 'timer fired : ', args
if COUNT < 10:
COUNT = COUNT + 1
return txTimer.CONTINUE
else:
txEvent.trigger(EXIT_EVENT)
return txTimer.STOP
timer = txTimer.txTimer(callback, ("abc", 123), 1000) # one second timer
txThread.yield(EXIT_EVENT)
##########################################################################
# IO Processing
##########################################################################
import sys
import txSync
import txEvent
import txThread
COUNT = 0
EXIT_EVENT = txEvent.txEvent("EXIT")
def callback (*args):
global COUNT
read = raw_input("") # get data so to reset stdin fd state
print 'io fired : ', args, read
if COUNT < 10:
COUNT = COUNT + 1
else:
txEvent.trigger(EXIT_EVENT)
return
id = txSync.registerIO(callback,("abc",
123),sys.stdin.fileno(),txSync.IORead)
print '\nEntire something in the console window and then press turn...
repeat'
txThread.yield(EXIT_EVENT)
More information about the Python-list
mailing list