PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›twisted

twisted

  • Getting Started
  • API Reference

    • Configuration
    • Publish & Subscribe
    • Presence
    • Access Manager
    • Channel Groups
    • Message Persistence
    • Mobile Push
    • Miscellaneous
  • Status Events
  • Troubleshooting
  • Change Log
  • Feature Support
  • Platform Support
  • Reconnection Policies

Troubleshooting PubNub Python-Twisted SDK

Python version support

Python SDK versions 5.0.0 and higher no longer support Python v2.7 and the Twisted and Tornado frameworks. If you require support for any of these, use SDK version 4.8.1.

Note that PubNub will stop supporting versions of Python lower than 3.7 by the end of 2021.

Deprecated

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!

How to enable logging

Use this code to enable logging:

import pubnub
import logging

pubnub.set_stream_logger('pubnub', logging.DEBUG)

How to find the version of your SDK

You can access your SDK version via constant:

from pubnub import PubNubTwisted

PubNubTwisted.SDK_VERSION

Error handling with deferred()

In case of deferred() calls, you should add error callback via addErrback to returned deferred. Errors that will be passed to given errback will wrapped out by either TwistedEnvelope or PubNubTwistedException which both implement two object fields:

  • e.result - a request result object in case of success, otherwise None.
  • e.status - PNStatus object with useful information about the finished request. You may check if it was an error or a success using e.is_error() helper.

deferred() usage

def publish():
    def succ(envelope):
        print(str(envelope.result))

    def errback(error):
        print("Error %s" % str(e))
        print("Error category #%d" % e.status.category)

    pubnub.publish().channel("my_channel").message("hello!").deferred().addCallback(succ).addErrback(errback)
← Status EventsChange Log →
  • How to enable logging
  • How to find the version of your SDK
  • Error handling with deferred()
© PubNub Inc. - Privacy Policy