[Twisted-Python] Simple app pickle issue when stopping

Alexander May alex-news at comcast.net
Sat May 15 15:14:49 EDT 2004


Still trying to learn/understand twisted.  Mind exploding/getting
frustrated.  I created this very simple app:

#!/usr/bin/python
from twisted.application import internet, service from twisted.web import
resource, server

class SimpleResource(resource.Resource):
  def __init__(self):
    resource.Resource.__init__(self)
    self.isLeaf=1
  def render_GET(self, request):
    return 'simple'

application = service.Application('server') serviceCollection =
service.IServiceCollection(application)
internet.TCPServer(8080,server.Site(SimpleResource())).setServiceParent(serv
iceCollection)

Then I run "twistd -y scratch.py" and it starts up correctly.  Great.
I can go to http://localhost:8080 and see the web page "simple".  Wonderful.
I hit control^C to stop the server and I get pickling errors.  Not good.
Call stack listed below:

IF I go into the python interactive environment and import sratch (and
pickle), I can instantiate SimpleResrouce and pickle it with no problem.
Help!

Alex

Call stack:
C:\Documents and Settings\Alexander May\My
Documents\maygold-dev\central-server>twistd -y scratch.py
2004/05/15 14:51 Eastern Daylight Time [-] Log opened.
2004/05/15 14:51 Eastern Daylight Time [-] twistd 1.2.0
(C:\Python23\python.exe 2.3.3) starting up
2004/05/15 14:51 Eastern Daylight Time [-] reactor class:
twisted.internet.default.SelectReactor
2004/05/15 14:51 Eastern Daylight Time [-] twisted.web.server.Site starting
on 8080
2004/05/15 14:51 Eastern Daylight Time [-] Starting factory
<twisted.web.server.Site instance at 0x00C52B70>
2004/05/15 14:51 Eastern Daylight Time [HTTPChannel,0,127.0.0.1] 127.0.0.1 -
- [15/May/2004:18:51:26 +0000] "GET / HTTP 1.1" 200 6 "-" "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1)"
2004/05/15 14:51 Eastern Daylight Time [-] (Port 8080 Closed)
2004/05/15 14:51 Eastern Daylight Time [-] Stopping factory
<twisted.web.server.Site instance at 0x00C52B70>
2004/05/15 14:51 Eastern Daylight Time [-] Saving server application to
server-shutdown.tap...
2004/05/15 14:51 Eastern Daylight Time [-] Traceback (most recent call
last):
          File "C:\Python23\Lib\site-packages\twisted\internet\defer.py",
line 227, in callback
            self._startRunCallbacks(result)
          File "C:\Python23\Lib\site-packages\twisted\internet\defer.py",
line 288, in _startRunCallbacks
            self._runCallbacks()
          File "C:\Python23\Lib\site-packages\twisted\internet\defer.py",
line 313, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "C:\Python23\Lib\site-packages\twisted\internet\base.py",
line 317, in _cbContinueSystemEvent
            self._continueSystemEvent(eventType)
        --- <exception caught here> ---
          File "C:\Python23\Lib\site-packages\twisted\internet\base.py",
line 325, in _continueSystemEvent
            callable(*args, **kw)
          File "C:\Python23\Lib\site-packages\twisted\persisted\sob.py",
line 135, in save
            self._saveTemp(filename, passphrase, dumpFunc)
          File "C:\Python23\Lib\site-packages\twisted\persisted\sob.py",
line 103, in _saveTemp
            dumpFunc(self.original, f)
          File "C:\Python23\Lib\site-packages\twisted\persisted\sob.py",
line 119, in dumpFunc
            pickle.dump(obj, file, 1)
        cPickle.PicklingError: Can't pickle __builtin__.SimpleResource:
attribute lookup __builtin__.SimpleResource faied

2004/05/15 14:51 Eastern Daylight Time [-] Main loop terminated.
2004/05/15 14:51 Eastern Daylight Time [-] Server Shut Down.






More information about the Twisted-Python mailing list