Pair of filenos read/write each other?

Jack Bates tdhfwh at nottheoilrig.com
Thu Aug 15 11:56:10 EDT 2013


On Wed, Aug 14, 2013 at 01:17:40AM +0100, Rhodri James wrote:
> On Wed, 14 Aug 2013 00:10:41 +0100, Jack Bates <tdhfwh at nottheoilrig.com>  
> wrote:
> 
> > Can anyone suggest a way to get a pair of file descriptor numbers such  
> > that data written to one can be read from the other and vice versa?
> >
> > Is there anything like os.pipe() where you can read/write both ends?
> 
> Sockets?  It depends a bit on what you're trying to do, exactly.  If you  
> give us a bit more context, we might be able to give you better advice.

Thanks, I am writing a fixture to test an app. The app normally uses the Python
wrapper for the GnuTLS library to handshake with a service that I want to
mock up in my fixture. The app passes a file descriptor number to
gnutls_transport_set_ptr()

When I test the app, the app and fixture run in the same process. I want a file
descriptor number I can foist on the app, and in the fixture access what is
read/written to it by the GnuTLS wrapper.



More information about the Python-list mailing list