[Twisted-Python] Re: [Pyobjc-dev] Re: pdb in PyObjC apps?

Bob Ippolito bob at redivi.com
Tue Aug 19 08:06:42 MDT 2003


On Tuesday, Aug 19, 2003, at 05:45 America/New_York, Michael Hudson 
wrote:

> Zachery Bir <zbir at urbanape.com> writes:
>
>> Note to self: Don't use pdb and try to catch it through
>> double-clicking  the app :)
>
> :-)
>
> It shouldn't be *too* outrageously hard to teach my pyrepl interactive
> tool how to cooperate with the Cocoa run loop (you need a way to give
> an fd to Cocoa and say "give me control when there's something to read
> on this" and I'm sure I saw one of them somewhere) in which case you
> could have an interactive session running alongside your
> application... Hmm, where's that can of tuits?

I've developed a CoreFoundation reactor for Twisted that would 
facilitate this sort of thing.  It's not mainline yet because I haven't 
had time to fully test and write enough examples -- it does work, but 
I'm not currently comfortable putting it in the rest of Twisted yet 
(especially due to the Pyrex build dependency).

Here's what you would do (this obviously needs Developer Tools 
installed):

Download Pyrex 0.8.2

Modify Pyrex/Compiler/Nodes.py .. change the block starting on line 160 
to this (small fix to allow system includes):
     for filename in env.include_files:
       if not (filename.startswith('<') and filename.endswith('>')):
         filename = '"%s"' % filename
       code.putln('#include %s' % filename)

Install Pyrex

Checkout CVS HEAD of Twisted

Build and install Twisted (or put twisted into your PYTHONPATH, I have 
a symlink of ~/src/Twisted/twisted at 
~/Library/Python/2.3/site-packages/twisted)

Go into Twisted/sandbox/etrepum/cfsupport

python setup.py build_ext -i

cd TWISTEDPACKAGE/internet
ln -s TWISTEDCVS/sandbox/etrepum/cfreactor.py .
ln -s TWISTEDCVS/sandbox/etrepum/cfsupport/cfsupport.so .

That should work, to test it check out the examples in 
TWISTEDCVS/sandbox/etrepum/examples/PyObjC (which obviously require 
PyObjC, you can get that from PackageManager)

Also note that the cfsupport module is enough to just get notifications 
on the fd, but I recommend using Twisted for anything that talks 
sockets anyway.

-bob





More information about the Twisted-Python mailing list