PythonTwistedTwistedTornadoAsyncioNativePython-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
 Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. Not setting the UUID can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.
  • V3 initiates via:
    pubnub = Pubnub(publish_key="demo", subscribe_key="demo")
  • V4 initiates via:
    pnconf = PNConfiguration()
    pnconf.subscribe_key = 'demo'
    pnconf.publish_key = 'demo'
    pnconf.uuid = "my_custom_uuid"
    pubnub = PubNub(pnconf)
  • V3 accepts callback and error callbacks as arguments:
    def callback(result):
    def errback(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.