title: TypeError: can't pickle file objects webpy and subprocess
body: <p>I am trying to make this following code possible. But I keep getting "TypeError: can't pickle file objects" error. I am both new to python and webpy. Can anyone tell how can I achieve this code.</p>
  
  <pre><code>import web 
  import subprocess
  
  web.config.debug = False
  urls = ( 
     "/start", "start",
     "/end", "end"
  )
  app = web.application(urls, locals())
  s = web.session.Session(app, web.session.DiskStore('sessions'), initializer={"p": None})
  
  class start:
      def GET(self):
          s.p = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          return ""
  
  class end:
      def GET(self):
          out, err = s.p.communicate();
          return out 
  
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p>the error I keep seeing is 
  python27/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
      raise TypeError, "can't pickle %s objects" % base.<strong>name</strong>
  TypeError: can't pickle file objects</p>