piiiipes!!

Jeff Grimmett grimmtoothtoo at yahoo.com
Thu Aug 30 23:18:06 EDT 2001


Ongoing telnet client battles...

I've got the thing set up and it seems to be handling a lot of junk
thrown at it OK. Now I want to use it to work with child processes.
This is important to maintain modularity, but also because some of the
child processes must be allowed to call each other in an arbitrary
sequence.

So here's the scenario: I have a SocketServer-based system. I have a
read and write handle to the remote client (for now, a telnet client).
Using popen*(), I can call a child process via pipes, and this returns
two (or three, depending) file objects.

Under *nix it would be fairly simple to harness the two together,
sending the output of the client to the child and vice-versa, using
select.select().

Under Win32, which it must also work under, select() won't fly because
(from the docs) 'the underlying select() function is provided by the
WinSock library, and does not handle file desciptors that don't
originate from WinSock. '

In C, which is where the basic framework for this originated, the
process was also simple:

  while(t = read(fp1,args))
  {
      process_and_look_for_control_commands()
      err = write(fp2,t,args)
  }

  while(t = read(fp2,args))
  {
      process_and_look_for_control_commands()
      err = write(fp1,t,args)
  }

Granted it's brute force, but it got the job done.  Unfortunately,
something like:

  while (t = file_1_read_object.read()):
     process_stuff()
     file_2_write_object.write(t)

is not acceptable in Python (or at least, I always get syntax error)

I'm continuing to play around in the sandbox but I think I'm starting
to recurse a bit ...


Suggestions? Comments? Voodoo curses?
Thanks!



More information about the Python-list mailing list