Troubleshooting Python-Asyncio SDK
This page explains how to find the version of the PubNub Python-Asyncio Software Development Kit (SDK) and how to log it for troubleshooting and support.
How to find the version of your SDK
Knowing your Software Development Kit (SDK) version helps with troubleshooting and reporting bugs. You can access the SDK version using the SDK_VERSION
constant.
Access your SDK version via constant
The following snippet demonstrates how to retrieve and display the SDK version using the PubNubAsyncio
class.
Steps to access the SDK version
- Import the required modules.
- Retrieve the version with
PubNubAsyncio.SDK_VERSION
. - Log or print the version for future reference.
import asyncio
import os
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub_asyncio import PubNubAsyncio
async def display_sdk_info(pubnub: PubNubAsyncio):
# Get and display the SDK version
sdk_version = PubNubAsyncio.SDK_VERSION
print(f"PubNub Asyncio SDK Version: {sdk_version}")
if __name__ == "__main__":
# Configuration for PubNub instance
pn_config = PNConfiguration()
show all 33 linesOnce you retrieve the SDK version, you can use this information for several tasks. For example:
- Reporting issues to support
- Diagnosing compatibility problems
- Verifying if a specific feature is available
- Checking if your application needs an upgrade
Log the SDK version during initialization
You can also log the SDK version during initialization to keep a record of versions used across deployments.
import os
import logging
import asyncio
from pubnub.pubnub import set_stream_logger # Correct import for set_stream_logger
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub_asyncio import PubNubAsyncio
# Set up logging
logging.basicConfig(level=logging.INFO)
set_stream_logger('pubnub', logging.INFO)
logger = logging.getLogger('pubnub_app')
async def init_and_log_version(pubnub):
logger.info(f"Initializing PubNub with SDK version: {PubNubAsyncio.SDK_VERSION}")
show all 43 lines