KeyboardInterrupt being lost?

2005-10-14 Thread Operation Latte Thunder
I have a simple test proggie that isn't behaving like I expect ( found
below ).  The script will infinitely run ( as expected ), but seems to
completely ignore control-C's.  Shouldn't the interpreter pass along
KeyboardInterrupts and break out of the while loop, or am I missing
something?

Using python 2.4.2 on linux ( if it matters )

-- Script Below --

import threading, traceback, time

class TestThread ( threading.Thread ):
def __init__ ( self ):
threading.Thread.__init__ ( self )
def run ( self ):
print Starting...
while True:
time.sleep ( 1 )
return

if __name__ == '__main__':
test = TestThread ( )
test.start()
print Started...
test.join()


-- 
chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: twisted jabber and xmlstream

2005-05-04 Thread Operation Latte Thunder
Sylvain Thenault [EMAIL PROTECTED] wrote:
 you can find some examples in our fatima project, a jabber bot testing
 client, available at http://www.logilab.org/projects/fatima/0.1
 You'll find a jabber.py module in the distribution containing jabber
 related code.
 
 hope that helps

thanks, I'll check it out!

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list


twisted jabber and xmlstream

2005-05-03 Thread Operation Latte Thunder
I am playing around with Jabber with Twisted.  I can receive messages just
fine, and thats great, however, I am a bit confused about how to actually
_send_ messages.  From what I've seen, I need to call send() on the
xmlstream I get when I am auth'd... and thats where I get stuck.  Do I
need to create the jabber message documents myself, or are there factory
methods that create message, presence, iq, etc messages for me.

Better yet, does anybody have an example on the web somewhere?

/goes back to staring at the XmlStream API doc...

TIA

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shutting down twisted reacotr

2005-04-28 Thread Operation Latte Thunder
Jason  Mobarak [EMAIL PROTECTED] wrote:
 Why do you want to do this in a thread? What's wrong with
 reactor.callLater?
 
 import time
 from twisted.internet import reactor
 
 def shutdown():
 
time.sleep(3)
print stopping
reactor.callFromThread(reactor.stop)
 
 reactor.callInThread(shutdown)
 reactor.run()

In the app I am playing with, I have a thread that reads from the console.
When it terminates, I wanted it to shut down the reactor and couldn't use
callLater.  However, callFromThread worked perfectly.   I guess I need to
look at the docs some more to understand why its necessary 

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list


Shutting down twisted reacotr

2005-04-27 Thread Operation Latte Thunder
I have a simple ( I hope ) problem that I have been baning my head against
all day.  I have isolated it down to a very small demo script, which I
will include below.

Basically, I want to have twisted run until an event makes it stop. My
problem is that my reactor.stop() doesn't seem to do anything if its not
called via a calllater or an equivilent.  Unfortunately, my google-fu
seems weak today, as I have not been able to discern its solution.
Without further adieu:

from thread import start_new_thread
import time
from twisted.internet import reactor

def shutdown():
time.sleep( 1 )
print Stopping
reactor.stop()

start_new_thread ( shutdown, () )

reactor.run()
print done

This will continue to run even after printing Stopping

any ideas?

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list


freeze and expat

2005-04-21 Thread Operation Latte Thunder
I am playing around with jabberpy, and on a lark decided to try to freeze
one of the included samples, test_client.py

The freeze/build worked fine, but when I attempted to run the resulting
binary, I got an error hinting that it couldn't find parsers.expat:

canal:/home/chris/build% ./test_client
Traceback (most recent call last):
  File /home/chris/build/../test_client.py, line 15, in ?
import jabber
  File /usr/lib/python2.3/site-packages/jabber.py, line 67, in ?
import xmlstream
  File /usr/lib/python2.3/site-packages/xmlstream.py, line 36, in ?
import xml.parsers.expat
ImportError: No module named parsers.expat

I have tried this with python2.3.5 and 2.4.1, and played around with the -m
option on the freeze cmd line, but no joy.  Google seems to delight in
frustating me...

In a much simpler case than the test_client.py, the following also fails:

import xml.parsers.expat
print Hello world

Though it runs from the interpreter... ideas?

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list