Troubleshoot the PubNub Python-Asyncio SDK

This page shows how to find the version of the PubNub Python-Asyncio SDK and log it for troubleshooting and support.

How to find the version of your SDK​

Your SDK version helps with troubleshooting and bug reports. Read it from the SDK_VERSION constant.

Access your SDK version via constant​

The following snippet prints the SDK version from the PubNubAsyncio class.

Steps to access the SDK version​

  1. Import the required modules.
  2. Retrieve the version with PubNubAsyncio.SDK_VERSION.
  3. Log or print the version for future reference.
1import asyncio
2import os
3from pubnub.pnconfiguration import PNConfiguration
4from pubnub.pubnub_asyncio import PubNubAsyncio
5
6
7async def display_sdk_info(pubnub: PubNubAsyncio):
8 # Get and display the SDK version
9 sdk_version = PubNubAsyncio.SDK_VERSION
10 print(f"PubNub Asyncio SDK Version: {sdk_version}")
11
12
13if __name__ == "__main__":
14 # Configuration for PubNub instance
15 pn_config = PNConfiguration()
show all 33 lines

Use the SDK version to:

  • Report issues to support
  • Diagnose compatibility problems
  • Check whether a feature is available
  • Decide whether your application needs an upgrade

Log the SDK version during initialization​

Log the SDK version during initialization to keep a record of versions across deployments.

1import os
2import logging
3import asyncio
4from pubnub import set_stream_logger
5from pubnub.pnconfiguration import PNConfiguration
6from pubnub.pubnub_asyncio import PubNubAsyncio
7
8# Set up logging
9logging.basicConfig(level=logging.INFO)
10set_stream_logger('pubnub', logging.INFO)
11logger = logging.getLogger('pubnub_app')
12
13async def init_and_log_version(pubnub):
14 logger.info(f"Initializing PubNub with SDK version: {PubNubAsyncio.SDK_VERSION}")
15
show all 43 lines

Was this page useful?

Last updated on