B. Fixing IDLEfork

As described in Section 2.3.2, the latest stable version of IDLEfork at the time of writing (0.8.1) is unable to run multiple instances for different users on the same machine. The developers are in the process of fixing this but, until then, the following workaround was implemented:

The file protocol.py in the IDLEfork source was edited to allow the default_port to be altered by an external environment variable. The original line 322:

  default_port = 0x1D1E   # "IDlE"


  default_port = 0x1D1E   # "IDlE"
  # Hack added by CRW/MJW to workaround idle mis-design
  # idle is now called via a wrapper script which sets the
  # ENV variable IDLEPORT to PID+4096 -- we will use this
  # value rather than the default of 0x1D1E   -- 2002-05-09
      p = os.environ.get("IDLEPORT")
      if p: default_port = int(p)

The wrapper script used is the following:

  # Wrapper script for idle (idlefork 0.8.1) to allow multiple
  # separate instances to be run simultaneously by different users.
  # Implemented using a crude hack to the idle (fork) prog itself
  # (see idle-0.8.1)
  #                 CRW & MJW  2002-05-09
  import os
  thispid = os.getpid()
  portnumber = thispid + 4096
  os.putenv("IDLEPORT", str(portnumber))
  os.system("/usr/local/bin/python -Qnew /usr/local/bin/idle-0.8.1 -i")