TwistedTwistedTornadoAsyncioNativePythonPython-Twisted V3 to Python-Twisted V4 Migration Guide

 

NOTICE: Based on current web trends and our own usage data, PubNub's Python Twisted SDK is deprecated as of May 1, 2019. Deprecation means we will no longer be updating the Python Twisted SDK but will continue to support users currently using it. Please feel free to use our other Python SDK offerings as they will continue to be supported and maintained. If you would like to use the Python Twisted SDK specifically, we would love to work with you on keeping this project alive!

  • V3 exposes PubnubTwisted
  • V4 exposes PubNubTwisted
  • V3 initiates via:
    pubnub = Pubnub(publish_key="demo", subscribe_key="demo")
    
  • V4 initiates via:
    pnconf = PNConfiguration()
    
    pnconf.subscribe_key = 'demo'
    pnconf.publish_key = 'demo'
    
    pubnub = PubNub(pnconf)
  • V3 accepts callback and error callbacks as arguments:
    def callback(result):
        print(result)
    
    def errback(error):
        print(error)
    
    pubnub.publish('ch', 'Hi', callback=callback, error=errback)
  • V4 sync way
    envelope = yield pubnub.publish().channel('ch').message('Hi').deferred()
    
  • V3 exposes subscribe callbacks via method params.
  • V4 exposes the functionality via listeners.
  • V4 returns a status object for each transactional request in the envelope and in the status portion of a listener or a callback.