00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 00011 __facility__ = "Online" 00012 __abstract__ = "Event loopback test" 00013 __author__ = "A. Perazzo <perazzo@SLAC.Stanford.edu> SLAC - GLAST I&T/Online" 00014 __date__ = ("$Date: 2004/08/24 23:20:56 $").split(' ')[1] 00015 __version__ = "$Revision: 2.1 $" 00016 __release__ = "$Name: R04-12-00 $" 00017 __credits__ = "SLAC" 00018 00019 import LATTE.copyright_SLAC 00020 00021 import threading 00022 import select 00023 import LATTE.client.gLoopback as gLoopback 00024 00025 class EvtCli(object): 00026 def __init__(self): 00027 self.__loopback = gLoopback.Loopback() 00028 00029 def read(self): 00030 print "readfunction" 00031 try: 00032 rd, wr, ex = select.select([self.__loopback.socket()], [], [], None) 00033 print "select done" 00034 except Exception, msg: 00035 print msg 00036 return 00037 for fd in rd: 00038 if fd == self.__loopback.socket(): 00039 value = self.__loopback.acknowledge() 00040 print "shutdown!", value 00041 00042 def dontread(self): 00043 print "dont read called" 00044 self.__loopback.commit(0xbeef) 00045 print "dont read done" 00046 00047 00048 if __name__ == '__main__': 00049 evtcli = EvtCli() 00050 evtHandler = threading.Thread(None, evtcli.read, 'EventHandler',()) 00051 evtHandler.start() 00052 evtcli.dontread() 00053 print "done with threads" 00054